Skip to content

Commit

Permalink
Fixed onMapReady event on iOS to resemble onMapReady on Android (Closes
Browse files Browse the repository at this point in the history
react-native-maps#1793) (react-native-maps#1797)

Also: Closes react-native-maps#1776, Closes react-native-maps#1696, Closes react-native-maps#1680, Closes react-native-maps#1605)
Probably closes more issues related to iOS, panning and scrolling.
  • Loading branch information
danielgindi authored and christopherdro committed Nov 28, 2017
1 parent 1c47c65 commit 3c3fc5c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/ios/AirGoogleMaps/AIRGoogleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@property (nonatomic, assign) BOOL showsMyLocationButton;
@property (nonatomic, assign) BOOL showsIndoorLevelPicker;

- (void)didFinishTileRendering;
- (void)didPrepareMap;
- (BOOL)didTapMarker:(GMSMarker *)marker;
- (void)didTapPolyline:(GMSPolyline *)polyline;
- (void)didTapPolygon:(GMSPolygon *)polygon;
Expand Down
2 changes: 1 addition & 1 deletion lib/ios/AirGoogleMaps/AIRGoogleMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ - (void)setRegion:(MKCoordinateRegion)region {
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
}

- (void)didFinishTileRendering {
- (void)didPrepareMap {
if (self.onMapReady) self.onMapReady(@{});
}

Expand Down
18 changes: 10 additions & 8 deletions lib/ios/AirGoogleMaps/AIRGoogleMapManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@


@interface AIRGoogleMapManager() <GMSMapViewDelegate>

{
BOOL didCallOnMapReady;
}

@end

@implementation AIRGoogleMapManager
Expand Down Expand Up @@ -263,13 +266,12 @@ - (NSDictionary *)constantsToExport {
return @{ @"legalNotice": [GMSServices openSourceLicenseInfo] };
}

+ (BOOL)requiresMainQueueSetup {
return YES;
}

- (void)mapViewDidFinishTileRendering:(GMSMapView *)mapView {
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
[googleMapView didFinishTileRendering];
- (void)mapViewDidStartTileRendering:(GMSMapView *)mapView {
if (didCallOnMapReady) return;
didCallOnMapReady = YES;

AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
[googleMapView didPrepareMap];
}

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
Expand Down
14 changes: 10 additions & 4 deletions lib/ios/AirMaps/AIRMapManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ @interface AIRMapManager() <MKMapViewDelegate>
@end

@implementation AIRMapManager

{
BOOL didCallOnMapReady;
}

RCT_EXPORT_MODULE()

- (UIView *)view
Expand Down Expand Up @@ -708,6 +711,12 @@ - (void)mapView:(AIRMap *)mapView regionDidChangeAnimated:(__unused BOOL)animate

- (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
{
if (!didCallOnMapReady)
{
didCallOnMapReady = YES;
mapView.onMapReady(@{});
}

mapView.hasStartedRendering = YES;
[mapView beginLoading];
[self _emitRegionChangeEvent:mapView continuous:NO];
Expand All @@ -716,9 +725,6 @@ - (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
- (void)mapViewDidFinishRenderingMap:(AIRMap *)mapView fullyRendered:(BOOL)fullyRendered
{
[mapView finishLoading];
[mapView cacheViewIfNeeded];

mapView.onMapReady(@{});
}

#pragma mark Private
Expand Down

0 comments on commit 3c3fc5c

Please sign in to comment.