diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-08-24 11:43:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-24 11:43:54 -0700 |
commit | 2523f33ac440be1a817e50d2d8bdc4d9c5b0a9d9 (patch) | |
tree | 1e404d39d374ce03b318ce316ec6cce6d079ad65 /platform | |
parent | 7fb7bc0fbc519e1ac934eb1218c4a3032def9317 (diff) | |
download | qtlocation-mapboxgl-2523f33ac440be1a817e50d2d8bdc4d9c5b0a9d9.tar.gz |
[ios, macos] Expose name and default position of current style (#6127)
* [ios] Reset to style’s default position
* [ios, macos] Added name property to MGLStyle
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/src/MGLStyle.h | 7 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 4 | ||||
-rw-r--r-- | platform/ios/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.h | 14 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 10 |
5 files changed, 27 insertions, 9 deletions
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 3354d27a43..bc4c32da91 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -164,6 +164,13 @@ static const NSInteger MGLStyleDefaultVersion = 9; */ + (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version; +/** + The name of the style. + + You can customize the style’s name in Mapbox Studio. + */ +@property (readonly, copy, nullable) NSString *name; + #pragma mark Runtime Styling /** diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 7b6a36d834..e392cead3f 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -88,6 +88,10 @@ static NSURL *MGLStyleURL_emerald; return MGLStyleURL_emerald; } +- (NSString *)name { + return @(self.mapView.mbglMap->getStyleName().c_str()); +} + - (mbgl::style::Layer *)mbglLayerWithIdentifier:(NSString *)identifier { return self.mapView.mbglMap->getLayer(identifier.UTF8String); diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index b81acf63a6..24c1c8d70a 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -17,6 +17,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added [quadkey](https://msdn.microsoft.com/en-us/library/bb259689.aspx) support and limited WMS support in raster tile URL templates. ([#5628](https://github.com/mapbox/mapbox-gl-native/pull/5628)) * TileJSON manifests can now specify `"scheme": "tms"` to indicate the use of [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) coordinates. ([#2270](https://github.com/mapbox/mapbox-gl-native/pull/2270)) * Fixed rendering artifacts and missing glyphs that occurred after viewing a large number of CJK characters on the map. ([#5908](https://github.com/mapbox/mapbox-gl-native/pull/5908)) +* `-[MGLMapView resetPosition]` now resets to the current style’s default center coordinates, zoom level, direction, and pitch, if specified. ([#6127](https://github.com/mapbox/mapbox-gl-native/pull/6127)) * The `text-pitch-alignment` property is now supported in stylesheets for improved street label legibility on a tilted map. ([#5288](https://github.com/mapbox/mapbox-gl-native/pull/5288)) * The `icon-text-fit` and `icon-text-fit-padding` properties are now supported in stylesheets, allowing the background of a shield to automatically resize to fit the shield’s text. ([#5334](https://github.com/mapbox/mapbox-gl-native/pull/5334)) * The `circle-pitch-scale` property is now supported in stylesheets, allowing circle features in a tilted base map to scale or remain the same size as the viewing distance changes. ([#5576](https://github.com/mapbox/mapbox-gl-native/pull/5576)) diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 40a9ad51f7..57b74daa04 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -540,6 +540,14 @@ IB_DESIGNABLE - (IBAction)resetNorth; /** + Resets the map to the current style’s default viewport. + + If the style doesn’t specify a default viewport, the map resets to a minimum + zoom level, a center coordinate of (0, 0), and a northern heading. + */ +- (IBAction)resetPosition; + +/** The coordinate bounds visible in the receiver’s viewport. Changing the value of this property updates the receiver immediately. If you @@ -1195,12 +1203,6 @@ IB_DESIGNABLE - (void)emptyMemoryCache __attribute__((deprecated)); -/** - Resets the map to the minimum zoom level, a center coordinate of (0, 0), and - a northern heading. - */ -- (void)resetPosition; - @end NS_ASSUME_NONNULL_END diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index d588f797cc..c3091a588b 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1899,9 +1899,13 @@ public: - (void)resetPosition { - MGLMapCamera *camera = [MGLMapCamera camera]; - camera.altitude = MGLAltitudeForZoomLevel(0, 0, 0, self.frame.size); - self.camera = camera; + CGFloat pitch = _mbglMap->getDefaultPitch(); + CLLocationDirection heading = mbgl::util::wrap(_mbglMap->getDefaultBearing(), 0., 360.); + CLLocationDistance distance = MGLAltitudeForZoomLevel(_mbglMap->getDefaultZoom(), pitch, 0, self.frame.size); + self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(_mbglMap->getDefaultLatLng()) + fromDistance:distance + pitch:pitch + heading:heading]; } - (void)emptyMemoryCache |