diff --git a/platform/osx/sdk/Mapbox.m b/platform/osx/sdk/Mapbox.m index 661795a87..1ac5a2d81 100644 --- a/platform/osx/sdk/Mapbox.m +++ b/platform/osx/sdk/Mapbox.m @@ -1,5 +1,6 @@ #import +#import "../src/MGLMapView_Private.h" #import "../src/NSBundle+MGLAdditions.h" #import "../src/NSProcessInfo+MGLAdditions.h" #import "../../darwin/NSString+MGLAdditions.h" @@ -14,6 +15,7 @@ static void InitializeMapbox() { mgl_linkBundleCategory(); mgl_linkStringCategory(); mgl_linkProcessInfoCategory(); + mgl_linkMapViewIBCategory(); [MGLAccountManager class]; [MGLAnnotationImage class]; diff --git a/platform/osx/src/MGLMapView+IBAdditions.m b/platform/osx/src/MGLMapView+IBAdditions.m index d6c6b40cb..aaa4ddf1b 100644 --- a/platform/osx/src/MGLMapView+IBAdditions.m +++ b/platform/osx/src/MGLMapView+IBAdditions.m @@ -2,6 +2,8 @@ #import "MGLMapView_Private.h" +void mgl_linkMapViewIBCategory() {} + @implementation MGLMapView (IBAdditions) + (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL__ { diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 2796c5fdb..83b9bf009 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -209,7 +209,7 @@ public: } + (NSArray *)restorableStateKeyPaths { - return @[@"zoomLevel", @"direction"]; + return @[@"latitude", @"longitude", @"zoomLevel", @"direction"]; } - (void)commonInit { @@ -275,6 +275,8 @@ public: options.center = mbgl::LatLng(0, 0); options.zoom = _mbglMap->getMinZoom(); _mbglMap->jumpTo(options); + _pendingLatitude = NAN; + _pendingLongitude = NAN; } /// Adds zoom controls to the lower-right corner. @@ -770,6 +772,10 @@ public: #pragma mark Viewport ++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingCenterCoordinate { + return [NSSet setWithObjects:@"latitude", @"longitude", nil]; +} + - (CLLocationCoordinate2D)centerCoordinate { return MGLLocationCoordinate2DFromLatLng(_mbglMap->getLatLng()); } @@ -793,6 +799,22 @@ public: [self didChangeValueForKey:@"centerCoordinate"]; } +- (CLLocationDegrees)pendingLatitude { + return _pendingLatitude; +} + +- (void)setPendingLatitude:(CLLocationDegrees)pendingLatitude { + _pendingLatitude = pendingLatitude; +} + +- (CLLocationDegrees)pendingLongitude { + return _pendingLongitude; +} + +- (void)setPendingLongitude:(CLLocationDegrees)pendingLongitude { + _pendingLongitude = pendingLongitude; +} + - (double)zoomLevel { return _mbglMap->getZoom(); } diff --git a/platform/osx/src/MGLMapView_Private.h b/platform/osx/src/MGLMapView_Private.h index c206fffe6..d9d42c1b3 100644 --- a/platform/osx/src/MGLMapView_Private.h +++ b/platform/osx/src/MGLMapView_Private.h @@ -1,5 +1,7 @@ #import +void mgl_linkMapViewIBCategory(); + @interface MGLMapView (Private) /// True if the view or application is in a state where it is not expected to be