mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 22:23:37 +00:00
Fixed map annotation crash
This commit is contained in:
parent
df77c5ef1c
commit
0b505901ba
@ -47,27 +47,27 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
|||||||
[_regionChangeObserveTimer invalidate];
|
[_regionChangeObserveTimer invalidate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)reactSetFrame:(CGRect)frame
|
||||||
|
{
|
||||||
|
self.frame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)layoutSubviews
|
- (void)layoutSubviews
|
||||||
{
|
{
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
|
|
||||||
// Force resize subviews - only the layer is resized by default
|
|
||||||
CGRect mapFrame = self.frame;
|
|
||||||
self.frame = CGRectZero;
|
|
||||||
self.frame = mapFrame;
|
|
||||||
|
|
||||||
if (_legalLabel) {
|
if (_legalLabel) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
CGRect frame = _legalLabel.frame;
|
CGRect frame = _legalLabel.frame;
|
||||||
if (_legalLabelInsets.left) {
|
if (_legalLabelInsets.left) {
|
||||||
frame.origin.x = _legalLabelInsets.left;
|
frame.origin.x = _legalLabelInsets.left;
|
||||||
} else if (_legalLabelInsets.right) {
|
} else if (_legalLabelInsets.right) {
|
||||||
frame.origin.x = mapFrame.size.width - _legalLabelInsets.right - frame.size.width;
|
frame.origin.x = self.frame.size.width - _legalLabelInsets.right - frame.size.width;
|
||||||
}
|
}
|
||||||
if (_legalLabelInsets.top) {
|
if (_legalLabelInsets.top) {
|
||||||
frame.origin.y = _legalLabelInsets.top;
|
frame.origin.y = _legalLabelInsets.top;
|
||||||
} else if (_legalLabelInsets.bottom) {
|
} else if (_legalLabelInsets.bottom) {
|
||||||
frame.origin.y = mapFrame.size.height - _legalLabelInsets.bottom - frame.size.height;
|
frame.origin.y = self.frame.size.height - _legalLabelInsets.bottom - frame.size.height;
|
||||||
}
|
}
|
||||||
_legalLabel.frame = frame;
|
_legalLabel.frame = frame;
|
||||||
});
|
});
|
||||||
@ -93,7 +93,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRegion:(MKCoordinateRegion)region
|
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
|
||||||
{
|
{
|
||||||
// If location is invalid, abort
|
// If location is invalid, abort
|
||||||
if (!CLLocationCoordinate2DIsValid(region.center)) {
|
if (!CLLocationCoordinate2DIsValid(region.center)) {
|
||||||
@ -109,7 +109,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Animate to new position
|
// Animate to new position
|
||||||
[super setRegion:region animated:YES];
|
[super setRegion:region animated:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAnnotations:(MKShapeArray *)annotations
|
- (void)setAnnotations:(MKShapeArray *)annotations
|
||||||
|
@ -41,9 +41,11 @@ RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
|
|||||||
RCT_EXPORT_VIEW_PROPERTY(maxDelta, CGFloat)
|
RCT_EXPORT_VIEW_PROPERTY(maxDelta, CGFloat)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(minDelta, CGFloat)
|
RCT_EXPORT_VIEW_PROPERTY(minDelta, CGFloat)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(legalLabelInsets, UIEdgeInsets)
|
RCT_EXPORT_VIEW_PROPERTY(legalLabelInsets, UIEdgeInsets)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(region, MKCoordinateRegion)
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(annotations, MKShapeArray)
|
RCT_EXPORT_VIEW_PROPERTY(annotations, MKShapeArray)
|
||||||
|
RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap)
|
||||||
|
{
|
||||||
|
[view setRegion:json ? [RCTConvert MKCoordinateRegion:json] : defaultView.region animated:YES];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark MKMapViewDelegate
|
#pragma mark MKMapViewDelegate
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user