[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
This commit is contained in:
Minh Nguyễn
2016-08-24 11:43:54 -07:00
committed by GitHub
parent 7fb7bc0fbc
commit 2523f33ac4
5 changed files with 27 additions and 9 deletions

View File

@@ -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
/**

View File

@@ -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);

View File

@@ -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))

View File

@@ -539,6 +539,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.
@@ -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

View File

@@ -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