Skip to content

Commit d0ac017

Browse files
danielgindichristopherdro
authored andcommitted
Fixed onMapReady event on iOS to resemble onMapReady on Android (Closes 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.
1 parent 489e1f3 commit d0ac017

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

lib/ios/AirGoogleMaps/AIRGoogleMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
@property (nonatomic, assign) BOOL showsMyLocationButton;
4343
@property (nonatomic, assign) BOOL showsIndoorLevelPicker;
4444

45-
- (void)didFinishTileRendering;
45+
- (void)didPrepareMap;
4646
- (BOOL)didTapMarker:(GMSMarker *)marker;
4747
- (void)didTapPolyline:(GMSPolyline *)polyline;
4848
- (void)didTapPolygon:(GMSPolygon *)polygon;

lib/ios/AirGoogleMaps/AIRGoogleMap.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ - (void)setRegion:(MKCoordinateRegion)region {
155155
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
156156
}
157157

158-
- (void)didFinishTileRendering {
158+
- (void)didPrepareMap {
159159
if (self.onMapReady) self.onMapReady(@{});
160160
}
161161

lib/ios/AirGoogleMaps/AIRGoogleMapManager.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232

3333

3434
@interface AIRGoogleMapManager() <GMSMapViewDelegate>
35-
35+
{
36+
BOOL didCallOnMapReady;
37+
}
38+
3639
@end
3740

3841
@implementation AIRGoogleMapManager
@@ -263,13 +266,12 @@ - (NSDictionary *)constantsToExport {
263266
return @{ @"legalNotice": [GMSServices openSourceLicenseInfo] };
264267
}
265268

266-
+ (BOOL)requiresMainQueueSetup {
267-
return YES;
268-
}
269-
270-
- (void)mapViewDidFinishTileRendering:(GMSMapView *)mapView {
271-
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
272-
[googleMapView didFinishTileRendering];
269+
- (void)mapViewDidStartTileRendering:(GMSMapView *)mapView {
270+
if (didCallOnMapReady) return;
271+
didCallOnMapReady = YES;
272+
273+
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
274+
[googleMapView didPrepareMap];
273275
}
274276

275277
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {

lib/ios/AirMaps/AIRMapManager.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ @interface AIRMapManager() <MKMapViewDelegate>
3636
@end
3737

3838
@implementation AIRMapManager
39-
39+
{
40+
BOOL didCallOnMapReady;
41+
}
42+
4043
RCT_EXPORT_MODULE()
4144

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

709712
- (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
710713
{
714+
if (!didCallOnMapReady)
715+
{
716+
didCallOnMapReady = YES;
717+
mapView.onMapReady(@{});
718+
}
719+
711720
mapView.hasStartedRendering = YES;
712721
[mapView beginLoading];
713722
[self _emitRegionChangeEvent:mapView continuous:NO];
@@ -716,9 +725,6 @@ - (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
716725
- (void)mapViewDidFinishRenderingMap:(AIRMap *)mapView fullyRendered:(BOOL)fullyRendered
717726
{
718727
[mapView finishLoading];
719-
[mapView cacheViewIfNeeded];
720-
721-
mapView.onMapReady(@{});
722728
}
723729

724730
#pragma mark Private

0 commit comments

Comments
 (0)