Skip to content

Commit 7b9ed3d

Browse files
pethapatricio
authored and
patricio
committed
Set initial region on view (react-native-maps#1579)
1 parent 2c8ddfe commit 7b9ed3d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/ios/AirMaps/AIRMapManager.m

+12-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,17 @@ - (UIView *)view
9797
RCT_EXPORT_VIEW_PROPERTY(onMarkerDrag, RCTDirectEventBlock)
9898
RCT_EXPORT_VIEW_PROPERTY(onMarkerDragEnd, RCTDirectEventBlock)
9999
RCT_EXPORT_VIEW_PROPERTY(onCalloutPress, RCTDirectEventBlock)
100-
RCT_EXPORT_VIEW_PROPERTY(initialRegion, MKCoordinateRegion)
100+
RCT_CUSTOM_VIEW_PROPERTY(initialRegion, MKCoordinateRegion, AIRMap)
101+
{
102+
if (json == nil) return;
103+
104+
// don't emit region change events when we are setting the initialRegion
105+
BOOL originalIgnore = view.ignoreRegionChanges;
106+
view.ignoreRegionChanges = YES;
107+
[view setInitialRegion:[RCTConvert MKCoordinateRegion:json]];
108+
view.ignoreRegionChanges = originalIgnore;
109+
}
110+
101111
RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, CGFloat)
102112
RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, CGFloat)
103113

@@ -665,7 +675,7 @@ - (void)mapViewDidFinishRenderingMap:(AIRMap *)mapView fullyRendered:(BOOL)fully
665675
{
666676
[mapView finishLoading];
667677
[mapView cacheViewIfNeeded];
668-
678+
669679
mapView.onMapReady(@{});
670680
}
671681

0 commit comments

Comments
 (0)