From 0ef1293dada1490c808ae821228d5a2f3324afdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 9 Sep 2016 10:17:42 -0700 Subject: [core, android, ios, macos, qt] v10 default styles Upgraded from v9 default styles to v10 wherever the developer expects to get the latest and greatest, as well as in a couple tests where it may be beneficial to ensure that we can handle a two-digit version number in the style URL. Cherry-picked from ed54849e9909e7f7cd8724b39b2bc94f16cf9a11. --- platform/darwin/src/MGLStyle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index bd17fdec44..0e1403b114 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN the constant itself. Such details may change significantly from version to version. */ -static MGL_EXPORT const NSInteger MGLStyleDefaultVersion = 9; +static MGL_EXPORT const NSInteger MGLStyleDefaultVersion = 10; /** The proxy object for the current map style. -- cgit v1.2.1 From d85471b7deb9c57973f9b70e0dfe4a8f386c8a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 9 Sep 2016 10:29:45 -0700 Subject: [ios, macos] Updated documented default style version MGLStyleDefaultVersion is just for Streets now. Deleted style version documentation tests because not all styles are on the same version. Cherry-picked from ca97dd8cf4c70a5ed380c99700749fd3239715f0. --- platform/darwin/src/MGLStyle.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 0e1403b114..ab5a20686a 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -10,9 +10,9 @@ NS_ASSUME_NONNULL_BEGIN /** - A version number identifying the default version of the suite of default styles - provided by Mapbox. This version number may be passed into one of the - “StyleURLWithVersion” class methods of MGLStyle. + A version number identifying the default version of the Mapbox Streets style + obtained through the `-streetsStyleURL` method. This version number may also be + passed into the `-streetsStyleURLWithVersion:` method. The value of this constant generally corresponds to the latest released version as of the date on which this SDK was published. You can use this constant to @@ -72,7 +72,7 @@ MGL_EXPORT is specified explicitly. @param version The style’s latest released version. As of publication, the - current version is `9`. + current version is `10`. */ + (NSURL *)streetsStyleURLWithVersion:(NSInteger)version; @@ -91,7 +91,7 @@ MGL_EXPORT Outdoors is a general-purpose style tailored to outdoor activities. @param version The style’s latest released version. As of publication, the - current version is `9`. + current version is `10`. */ + (NSURL *)outdoorsStyleURLWithVersion:(NSInteger)version; @@ -173,7 +173,7 @@ MGL_EXPORT Streets. @param version The style’s latest released version. As of publication, the - current version is `9`. + current version is `10`. */ + (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version; -- cgit v1.2.1 From c5ee41a93a1f012acf41f29dc8bd75dc736ff4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 25 Apr 2017 20:52:47 -0400 Subject: [ios, macos] Undeprecated unversioned style URL factory methods Undeprecated the unversioned style URL factory methods in MGLStyle for consistency with the Android and Qt SDKs. Added warnings about using them with the runtime styling API. Refactored mbgl::util::default_styles to track different versions for different styles. Cherry-picked from 9e384b78fbcf46d66d390122eefdf273f91b314e. --- platform/darwin/src/MGLStyle.h | 104 ++++++++++++++++++++++++++++++---------- platform/darwin/src/MGLStyle.mm | 10 +--- 2 files changed, 81 insertions(+), 33 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index ab5a20686a..49898a1863 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -52,15 +52,22 @@ MGL_EXPORT #pragma mark Accessing Default Styles /** - Returns the URL to version 8 of the - Mapbox Streets style. + Returns the URL to the current version of the + Mapbox Streets style as of + publication. Streets is a general-purpose style with detailed road and transit networks. `MGLMapView` and `MGLTilePyramidOfflineRegion` use Mapbox Streets when no style is specified explicitly. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-streetsStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. */ -+ (NSURL *)streetsStyleURL __attribute__((deprecated("Use -streetsStyleURLWithVersion:."))); ++ (NSURL *)streetsStyleURL; /** Returns the URL to the given version of the @@ -71,8 +78,7 @@ MGL_EXPORT `MGLMapView` and `MGLTilePyramidOfflineRegion` use Mapbox Streets when no style is specified explicitly. - @param version The style’s latest released version. As of publication, the - current version is `10`. + @param version A specific version of the style. */ + (NSURL *)streetsStyleURLWithVersion:(NSInteger)version; @@ -84,71 +90,103 @@ MGL_EXPORT */ + (NSURL *)emeraldStyleURL __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/emerald-v8”."))); +/** + Returns the URL to the current version of the + Mapbox Outdoors style as of + publication. + + Outdoors is a general-purpose style tailored to outdoor activities. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-outdoorsStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. + */ ++ (NSURL *)outdoorsStyleURL; + /** Returns the URL to the given version of the Mapbox Outdoors style. Outdoors is a general-purpose style tailored to outdoor activities. - @param version The style’s latest released version. As of publication, the - current version is `10`. + @param version A specific version of the style. */ + (NSURL *)outdoorsStyleURLWithVersion:(NSInteger)version; /** - Returns the URL to version 8 of the + Returns the URL to the current version of the Mapbox Light style. Light is a subtle, light-colored backdrop for data visualizations. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-lightStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. */ -+ (NSURL *)lightStyleURL __attribute__((deprecated("Use -lightStyleURLWithVersion:."))); ++ (NSURL *)lightStyleURL; /** Returns the URL to the given version of the - Mapbox Light style. + Mapbox Light style as of + publication. Light is a subtle, light-colored backdrop for data visualizations. - @param version The style’s latest released version. As of publication, the - current version is `9`. + @param version A specific version of the style. */ + (NSURL *)lightStyleURLWithVersion:(NSInteger)version; /** - Returns the URL to version 8 of the + Returns the URL to the current version of the Mapbox Dark style. Dark is a subtle, dark-colored backdrop for data visualizations. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-darkStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. */ -+ (NSURL *)darkStyleURL __attribute__((deprecated("Use -darkStyleURLWithVersion:."))); ++ (NSURL *)darkStyleURL; /** Returns the URL to the given version of the - Mapbox Dark style. + Mapbox Dark style as of + publication. Dark is a subtle, dark-colored backdrop for data visualizations. - @param version The style’s latest released version. As of publication, the - current version is `9`. + @param version A specific version of the style. */ + (NSURL *)darkStyleURLWithVersion:(NSInteger)version; /** - Returns the URL to version 8 of the + Returns the URL to the current version of the Mapbox Satellite style. Satellite is high-resolution satellite and aerial imagery. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the raster tile sets included in the style – use the + `-satelliteStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. */ -+ (NSURL *)satelliteStyleURL __attribute__((deprecated("Use -satelliteStyleURLWithVersion:."))); ++ (NSURL *)satelliteStyleURL; /** Returns the URL to the given version of the - Mapbox Satellite style. + Mapbox Satellite style as + of publication. Satellite is high-resolution satellite and aerial imagery. - @param version The style’s latest released version. As of publication, the - current version is `9`. + @param version A specific version of the style. */ + (NSURL *)satelliteStyleURLWithVersion:(NSInteger)version; @@ -161,7 +199,24 @@ MGL_EXPORT Mapbox Satellite with unobtrusive labels and translucent roads from Mapbox Streets. */ -+ (NSURL *)hybridStyleURL __attribute__((deprecated("Use -satelliteStreetsStyleURLWithVersion:."))); ++ (NSURL *)hybridStyleURL __attribute__((deprecated("Use -satelliteStreetsStyleURL."))); + +/** + Returns the URL to the current version of the + Mapbox Satellite Streets + style as of publication. + + Satellite Streets combines the high-resolution satellite and aerial imagery of + Mapbox Satellite with unobtrusive labels and translucent roads from Mapbox + Streets. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-satelliteStreetsStyleURLWithVersion:` method instead. Such details may + change significantly from version to version. + */ ++ (NSURL *)satelliteStreetsStyleURL; /** Returns the URL to the given version of the @@ -172,8 +227,7 @@ MGL_EXPORT Mapbox Satellite with unobtrusive labels and translucent roads from Mapbox Streets. - @param version The style’s latest released version. As of publication, the - current version is `10`. + @param version A specific version of the style. */ + (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version; diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 81b6446e7f..ce9e55bb99 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -58,8 +58,6 @@ #pragma mark Default style URLs -static_assert(mbgl::util::default_styles::currentVersion == MGLStyleDefaultVersion, "mbgl::util::default_styles::currentVersion and MGLStyleDefaultVersion disagree."); - /// @param name The style’s marketing name, written in lower camelCase. /// @param fileName The last path component in the style’s URL, excluding the version suffix. #define MGL_DEFINE_STYLE(name, fileName) \ @@ -67,17 +65,13 @@ static_assert(mbgl::util::default_styles::currentVersion == MGLStyleDefaultVersi + (NSURL *)name##StyleURL { \ static dispatch_once_t onceToken; \ dispatch_once(&onceToken, ^{ \ - MGLStyleURL_##name = [self name##StyleURLWithVersion:8]; \ + MGLStyleURL_##name = [self name##StyleURLWithVersion:mbgl::util::default_styles::name.currentVersion]; \ }); \ return MGLStyleURL_##name; \ } \ \ + (NSURL *)name##StyleURL##WithVersion:(NSInteger)version { \ - if (mbgl::util::default_styles::currentVersion == version) { \ - return [NSURL URLWithString:@(mbgl::util::default_styles::name.url)]; \ - } else { \ - return [NSURL URLWithString:[@"mapbox://styles/mapbox/" #fileName "-v" stringByAppendingFormat:@"%li", (long)version]]; \ - } \ + return [NSURL URLWithString:[@"mapbox://styles/mapbox/" #fileName "-v" stringByAppendingFormat:@"%li", (long)version]]; \ } MGL_DEFINE_STYLE(streets, streets) -- cgit v1.2.1 From 886bf2528ff1615a50521e75fc6ea211cef3b8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Mon, 8 May 2017 17:45:22 -0700 Subject: [core, android, ios, macos] Added Traffic Day/Night to default styles The Styles API section of the Mapbox API Documentation site now lists Traffic Day v2 and Traffic Night v2, so this change adds those styles to all the places where styles are listed. Also switched iosapp and macosapp to unversioned style factory methods since MGLStyleDefaultVersion is no longer applicable for all styles. Cherry-picked from 4d6f54553d277c0af24a0b8ff03d2dd7e9284ca2. --- platform/darwin/src/MGLStyle.h | 62 +++++++++++++++++++++++++++++++++++++++++ platform/darwin/src/MGLStyle.mm | 4 ++- 2 files changed, 65 insertions(+), 1 deletion(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 49898a1863..26434eb492 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -231,6 +231,68 @@ MGL_EXPORT */ + (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version; +/** + Returns the URL to the current version of the + Mapbox Traffic Day + style. + + Traffic Day color-codes roads based on live traffic congestion data. Traffic + data is currently available in + these select countries. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-trafficDayStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. + */ ++ (NSURL *)trafficDayStyleURL; + +/** + Returns the URL to the given version of the + Mapbox Traffic Day + style as of publication. + + Traffic Day color-codes roads based on live traffic congestion data. Traffic + data is currently available in + these select countries. + + @param version A specific version of the style. + */ ++ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version; + +/** + Returns the URL to the current version of the + Mapbox Traffic Night + style. + + Traffic Night color-codes roads based on live traffic congestion data and is + designed to maximize legibility in low-light situations. Traffic data is + currently available in + these select countries. + + @warning The return value may change in a future release of the SDK. If you use + any feature that depends on a specific aspect of a default style – for + instance, the minimum zoom level that includes roads – use the + `-trafficNightStyleURLWithVersion:` method instead. Such details may change + significantly from version to version. + */ ++ (NSURL *)trafficNightStyleURL; + +/** + Returns the URL to the given version of the + Mapbox Traffic Night + style as of publication. + + Traffic Night color-codes roads based on live traffic congestion data and is + designed to maximize legibility in low-light situations. Traffic data is + currently available in + these select countries. + + @param version A specific version of the style. + */ ++ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version; + #pragma mark Accessing Metadata About the Style /** diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index ce9e55bb99..af02c31b6d 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -80,10 +80,12 @@ MGL_DEFINE_STYLE(light, light) MGL_DEFINE_STYLE(dark, dark) MGL_DEFINE_STYLE(satellite, satellite) MGL_DEFINE_STYLE(satelliteStreets, satellite-streets) +MGL_DEFINE_STYLE(trafficDay, traffic-day) +MGL_DEFINE_STYLE(trafficNight, traffic-night) // Make sure all the styles listed in mbgl::util::default_styles::orderedStyles // are defined above and also declared in MGLStyle.h. -static_assert(6 == mbgl::util::default_styles::numOrderedStyles, +static_assert(8 == mbgl::util::default_styles::numOrderedStyles, "mbgl::util::default_styles::orderedStyles and MGLStyle have different numbers of styles."); // Hybrid has been renamed Satellite Streets, so the last Hybrid version is hard-coded here. -- cgit v1.2.1 From c7acb5516b7575feb20f20d6f6cfaabede97c948 Mon Sep 17 00:00:00 2001 From: Jordan Kiley Date: Mon, 15 May 2017 11:27:10 -0700 Subject: [ios, macos] edited identity interpolation mode documentation (#8657) --- platform/darwin/src/MGLStyleValue.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyleValue.h b/platform/darwin/src/MGLStyleValue.h index 70074c8a13..2bb3aca4f4 100644 --- a/platform/darwin/src/MGLStyleValue.h +++ b/platform/darwin/src/MGLStyleValue.h @@ -75,9 +75,9 @@ typedef NS_ENUM(NSUInteger, MGLInterpolationMode) { */ MGLInterpolationModeCategorical, /** - Values between two stops are not interpolated. Instead, values are set to their - input value. Use identity interpolation mode to show attribute values that can be - used as style values. + Values between two stops are not interpolated. Instead, for any given feature, the + style value matches a value in that feature’s attributes dictionary. Use identity + interpolation mode to show attribute values that can be used as style values. */ MGLInterpolationModeIdentity }; -- cgit v1.2.1 From 30b919196b72351c43a5834b66a36068c0588fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 9 May 2017 18:36:20 -0700 Subject: [ios, macos] Factored out tile URL template guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Factored out redundant tile URL template documentation from the MGLRasterSource and MGLVectorSource documentation into a jazzy guide. This documentation used to live in one place, on a method on MGLTileSource, but that method had to be moved to MGLTileSource’s concrete subclasses. A jazzy guide is easier to link to, in any case. --- platform/darwin/src/MGLRasterSource.h | 91 ++--------------------------------- platform/darwin/src/MGLVectorSource.h | 91 ++--------------------------------- 2 files changed, 8 insertions(+), 174 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLRasterSource.h b/platform/darwin/src/MGLRasterSource.h index 519784f4f1..4f4b7c96c3 100644 --- a/platform/darwin/src/MGLRasterSource.h +++ b/platform/darwin/src/MGLRasterSource.h @@ -108,96 +108,13 @@ MGL_EXPORT Returns a raster source initialized an identifier, tile URL templates, and options. + Tile URL templates are strings that specify the URLs of the raster tile images + to load. See the “Tile URL Templates” + guide for information about the format of a tile URL template. + After initializing and configuring the source, add it to a map view’s style using the `-[MGLStyle addSource:]` method. - #### Tile URL templates - - Tile URL templates are strings that specify the URLs of the tile images to - load. Each template resembles an absolute URL, but with any number of - placeholder strings that the source evaluates based on the tile it needs to - load. For example: - -
    -
  • http://www.example.com/tiles/{z}/{x}/{y}.pbf could be - evaluated as http://www.example.com/tiles/14/6/9.pbf.
  • -
  • http://www.example.com/tiles/{z}/{x}/{y}{ratio}.png could be - evaluated as http://www.example.com/tiles/14/6/9@2x.png.
  • -
- - Tile sources support the following placeholder strings in tile URL templates, - all of which are optional: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Placeholder stringDescription
{x}The index of the tile along the map’s x axis according to Spherical - Mercator projection. If the value is 0, the tile’s left edge corresponds - to the 180th meridian west. If the value is 2z−1, - the tile’s right edge corresponds to the 180th meridian east.
{y}The index of the tile along the map’s y axis according to Spherical - Mercator projection. If the value is 0, the tile’s tile edge corresponds - to arctan(sinh(π)), or approximately 85.0511 degrees north. If the value - is 2z−1, the tile’s bottom edge corresponds to - −arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is - inverted if the options parameter contains - MGLTileSourceOptionTileCoordinateSystem with a value of - MGLTileCoordinateSystemTMS.
{z}The tile’s zoom level. At zoom level 0, each tile covers the entire - world map; at zoom level 1, it covers ¼ of the world; at zoom level 2, - 116 of the world, and so on. For tiles loaded by - a MGLRasterSource object, whether the tile zoom level - matches the map’s current zoom level depends on the value of the - source’s tile size as specified in the - MGLTileSourceOptionTileSize key of the - options parameter.
{bbox-epsg-3857}The tile’s bounding box, expressed as a comma-separated list of the - tile’s western, southern, eastern, and northern extents according to - Spherical Mercator (EPSG:3857) projection. The bounding box is typically - used with map services conforming to the - Web Map Service - protocol.
{quadkey}A quadkey indicating both the tile’s location and its zoom level. The - quadkey is typically used with - Bing Maps. -
{ratio}A suffix indicating the resolution of the tile image. The suffix is the - empty string for standard resolution displays and @2x for - Retina displays, including displays for which - NSScreen.backingScaleFactor or UIScreen.scale - is 3.
{prefix}Two hexadecimal digits chosen such that each visible tile has a - different prefix. The prefix is typically used for domain sharding.
- - For more information about the `{x}`, `{y}`, and `{z}` placeholder strings, - consult the - OpenStreetMap Wiki. - @param identifier A string that uniquely identifies the source in the style to which it is added. @param tileURLTemplates An array of tile URL template strings. Only the first diff --git a/platform/darwin/src/MGLVectorSource.h b/platform/darwin/src/MGLVectorSource.h index a48434f7a3..968be3c0e0 100644 --- a/platform/darwin/src/MGLVectorSource.h +++ b/platform/darwin/src/MGLVectorSource.h @@ -74,96 +74,13 @@ MGL_EXPORT Returns a vector source initialized an identifier, tile URL templates, and options. + Tile URL templates are strings that specify the URLs of the vector tiles to + load. See the “Tile URL Templates” + guide for information about the format of a tile URL template. + After initializing and configuring the source, add it to a map view’s style using the `-[MGLStyle addSource:]` method. - #### Tile URL templates - - Tile URL templates are strings that specify the URLs of the tile images to - load. Each template resembles an absolute URL, but with any number of - placeholder strings that the source evaluates based on the tile it needs to - load. For example: - -
    -
  • http://www.example.com/tiles/{z}/{x}/{y}.pbf could be - evaluated as http://www.example.com/tiles/14/6/9.pbf.
  • -
  • http://www.example.com/tiles/{z}/{x}/{y}{ratio}.png could be - evaluated as http://www.example.com/tiles/14/6/9@2x.png.
  • -
- - Tile sources support the following placeholder strings in tile URL templates, - all of which are optional: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Placeholder stringDescription
{x}The index of the tile along the map’s x axis according to Spherical - Mercator projection. If the value is 0, the tile’s left edge corresponds - to the 180th meridian west. If the value is 2z−1, - the tile’s right edge corresponds to the 180th meridian east.
{y}The index of the tile along the map’s y axis according to Spherical - Mercator projection. If the value is 0, the tile’s tile edge corresponds - to arctan(sinh(π)), or approximately 85.0511 degrees north. If the value - is 2z−1, the tile’s bottom edge corresponds to - −arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is - inverted if the options parameter contains - MGLTileSourceOptionTileCoordinateSystem with a value of - MGLTileCoordinateSystemTMS.
{z}The tile’s zoom level. At zoom level 0, each tile covers the entire - world map; at zoom level 1, it covers ¼ of the world; at zoom level 2, - 116 of the world, and so on. For tiles loaded by - a MGLRasterSource object, whether the tile zoom level - matches the map’s current zoom level depends on the value of the - source’s tile size as specified in the - MGLTileSourceOptionTileSize key of the - options parameter.
{bbox-epsg-3857}The tile’s bounding box, expressed as a comma-separated list of the - tile’s western, southern, eastern, and northern extents according to - Spherical Mercator (EPSG:3857) projection. The bounding box is typically - used with map services conforming to the - Web Map Service - protocol.
{quadkey}A quadkey indicating both the tile’s location and its zoom level. The - quadkey is typically used with - Bing Maps. -
{ratio}A suffix indicating the resolution of the tile image. The suffix is the - empty string for standard resolution displays and @2x for - Retina displays, including displays for which - NSScreen.backingScaleFactor or UIScreen.scale - is 3.
{prefix}Two hexadecimal digits chosen such that each visible tile has a - different prefix. The prefix is typically used for domain sharding.
- - For more information about the `{x}`, `{y}`, and `{z}` placeholder strings, - consult the - OpenStreetMap Wiki. - @param identifier A string that uniquely identifies the source in the style to which it is added. @param tileURLTemplates An array of tile URL template strings. Only the first -- cgit v1.2.1 From 7612e23dff48453abd00434b4fe8ba6645235875 Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Wed, 17 May 2017 14:52:19 -0700 Subject: [ios, macos] Change == to = in style function initializers --- platform/darwin/src/MGLStyleValue.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyleValue.mm b/platform/darwin/src/MGLStyleValue.mm index 33b6babadf..4dd6b550d8 100644 --- a/platform/darwin/src/MGLStyleValue.mm +++ b/platform/darwin/src/MGLStyleValue.mm @@ -128,7 +128,7 @@ const MGLStyleFunctionOption MGLStyleFunctionOptionDefaultValue = @"MGLStyleFunc return {}; } - if (self == [super init]) { + if (self = [super init]) { self.interpolationMode = interpolationMode; self.stops = stops; @@ -181,7 +181,7 @@ const MGLStyleFunctionOption MGLStyleFunctionOptionDefaultValue = @"MGLStyleFunc } - (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options { - if (self == [super init]) { + if (self = [super init]) { self.interpolationMode = interpolationMode; self.stops = stops; _attributeName = attributeName; @@ -251,7 +251,7 @@ const MGLStyleFunctionOption MGLStyleFunctionOptionDefaultValue = @"MGLStyleFunc } - (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options { - if (self == [super init]) { + if (self = [super init]) { self.interpolationMode = interpolationMode; self.stops = stops; _attributeName = attributeName; -- cgit v1.2.1 From 13dee80e2e90f06ee6cb2883dda16f7c4442aca5 Mon Sep 17 00:00:00 2001 From: Jordan Kiley Date: Mon, 1 May 2017 15:42:54 -0700 Subject: [ios, macos] Updated `maximumZoomLevel` description, cherry-picked #8818 (#8842) Cherry-picked from a3e4e67ea68c455178d5c5ef3d864972fcf41147. --- platform/darwin/src/MGLStyleLayer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyleLayer.h b/platform/darwin/src/MGLStyleLayer.h index d68aee29bc..7d181667d6 100644 --- a/platform/darwin/src/MGLStyleLayer.h +++ b/platform/darwin/src/MGLStyleLayer.h @@ -45,12 +45,12 @@ MGL_EXPORT @property (nonatomic, assign, getter=isVisible) BOOL visible; /** - The maximum zoom level at which the layer gets parsed and appears. + The maximum zoom level at which the layer gets parsed and appears. This value is a floating-point number. */ @property (nonatomic, assign) float maximumZoomLevel; /** - The minimum zoom level at which the layer gets parsed and appears. + The minimum zoom level at which the layer gets parsed and appears. This value is a floating-point number. */ @property (nonatomic, assign) float minimumZoomLevel; -- cgit v1.2.1 From a19fd817300abf00b81cba5765fda62c48057efa Mon Sep 17 00:00:00 2001 From: Jordan Kiley Date: Fri, 19 May 2017 16:08:03 -0700 Subject: [ios, macos] changed TRUE -> 'true' (#9059) fixes #9056 --- platform/darwin/src/MGLFillExtrusionStyleLayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.h b/platform/darwin/src/MGLFillExtrusionStyleLayer.h index 84f6bedde4..c4fb9aa77e 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.h +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.h @@ -46,7 +46,7 @@ typedef NS_ENUM(NSUInteger, MGLFillExtrusionTranslationAnchor) { layer.sourceLayerIdentifier = "building" layer.fillExtrusionHeight = MGLStyleValue(interpolationMode: .identity, sourceStops: nil, attributeName: "height", options: nil) layer.fillExtrusionBase = MGLStyleValue(interpolationMode: .identity, sourceStops: nil, attributeName: "min_height", options: nil) - layer.predicate = NSPredicate(format: "extrude == TRUE") + layer.predicate = NSPredicate(format: "extrude == 'true'") mapView.style?.addLayer(layer) ``` */ -- cgit v1.2.1 From e52249c17fb529c476569b6d7ef141be1bff7d7f Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Tue, 23 May 2017 10:59:24 -0400 Subject: [ios, macos] Light property implementation in MGLStyle (#9043) * [ios, macos] Add MGLLight to MGLStyle * [ios, macos] Implement Objc bindings for Light object * [ios, macos] Remove rawLight from MGLLight and re-implement it as value class * [ios, macos] Fix build on macos * [ios, macos] Add MGLLight documentation, Move MGLLightPosition to MGLLight * [ios, macos] Add MGLLight tests. * [ios, macos] Update changelogs * [ios, macos] Fix misspelling * [ios, macos] Fix MGLLightAnchor enum property names * [ios, macos] Update documentation. Improve varialble naming. * [ios, macos] Rename MGLLightPosition to MGLSphericalPosition * [ios, macos] Update data types of MGLSphericalPosition --- platform/darwin/src/MGLLight.h | 125 +++++++++++++++++++++ platform/darwin/src/MGLLight.mm | 117 +++++++++++++++++++ platform/darwin/src/MGLLight_Private.h | 23 ++++ platform/darwin/src/MGLStyle.h | 9 ++ platform/darwin/src/MGLStyle.mm | 17 +++ platform/darwin/src/MGLStyleValue_Private.h | 14 +++ platform/darwin/src/MGLTypes.h | 1 + platform/darwin/src/NSValue+MGLAdditions.h | 29 +++++ platform/darwin/src/NSValue+MGLAdditions.m | 23 ++++ .../src/NSValue+MGLStyleAttributeAdditions.h | 1 + .../src/NSValue+MGLStyleAttributeAdditions.mm | 15 ++- 11 files changed, 373 insertions(+), 1 deletion(-) create mode 100644 platform/darwin/src/MGLLight.h create mode 100644 platform/darwin/src/MGLLight.mm create mode 100644 platform/darwin/src/MGLLight_Private.h (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h new file mode 100644 index 0000000000..d9a22d60fa --- /dev/null +++ b/platform/darwin/src/MGLLight.h @@ -0,0 +1,125 @@ +#import + +#import "MGLFoundation.h" +#import "MGLStyleValue.h" + +NS_ASSUME_NONNULL_BEGIN + + +/** Options to specify extruded geometries are lit relative to the map or viewport. */ +typedef NS_ENUM(NSUInteger, MGLLightAnchor) { + /** The position of the light source is aligned to the rotation of the map. */ + MGLLightAnchorMap, + /** The position of the light source is aligned to the rotation of the viewport. */ + MGLLightAnchorViewport +}; + +/** + A structure containing information about the position of the light source + relative to lit geometries. + */ +typedef struct MGLSphericalPosition { + /** Distance from the center of the base of an object to its light. */ + CLLocationDistance radial; + /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds + to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, + and degrees proceed clockwise). */ + CLLocationDirection azimuthal; + /** Indicates the height of the light (from 0°, directly above, to 180°, directly below). */ + CLLocationDirection polar; +} MGLSphericalPosition; + +/** + Creates a new `MGLSphericalPosition` from the given radial, azimuthal, polar. + + @param radial The radial coordinate. + @param azimuthal The azimuthal angle. + @param polar The polar angle. + + @return Returns a `MGLSphericalPosition` struct containing the position attributes. + */ +NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CLLocationDistance radial, CLLocationDirection azimuthal, CLLocationDirection polar) { + MGLSphericalPosition position; + position.radial = radial; + position.azimuthal = azimuthal; + position.polar = polar; + + return position; +} + +/** + An `MGLLight` object represents the light source for extruded geometries in `MGLStyle`. + */ +MGL_EXPORT +@interface MGLLight : NSObject + +/** + `anchor` Whether extruded geometries are lit relative to the map or viewport. + + This property corresponds to the anchor + light property in the Mapbox Style Specification. + */ +@property (nonatomic) MGLLightAnchor anchor; + +/** + Values describing animated transitions to `anchor` property. + */ +@property (nonatomic) MGLTransition anchorTransition; + + +/** + Position of the light source relative to lit (extruded) geometries. + + This property corresponds to the position + light property in the Mapbox Style Specification. + */ +@property (nonatomic) MGLStyleValue * position; + +/** + Values describing animated transitions to `position` property. + */ +@property (nonatomic) MGLTransition positionTransiton; + + +#if TARGET_OS_IPHONE +/** + Color tint for lighting extruded geometries. + + This property corresponds to the color + light property in the Mapbox Style Specification. + */ +@property (nonatomic) MGLStyleValue *color; +#else + +/** + Color tint for lighting extruded geometries. + */ +@property (nonatomic) MGLStyleValue *color; +#endif + +/** + Values describing animated transitions to `color` property. + */ +@property (nonatomic) MGLTransition colorTransiton; + + +/** + Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast. + + This property corresponds to the intensity + light property in the Mapbox Style Specification. + */ +@property(nonatomic) MGLStyleValue *intensity; + +/** + Values describing animated transitions to `intensity` property. + */ +@property (nonatomic) MGLTransition intensityTransition; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLight.mm b/platform/darwin/src/MGLLight.mm new file mode 100644 index 0000000000..02d55e76ed --- /dev/null +++ b/platform/darwin/src/MGLLight.mm @@ -0,0 +1,117 @@ +#import "MGLLight.h" + +#import "MGLTypes.h" +#import "NSDate+MGLAdditions.h" +#import "MGLStyleValue_Private.h" +#import "NSValue+MGLAdditions.h" + +#import +#import + +namespace mbgl { + + MBGL_DEFINE_ENUM(MGLLightAnchor, { + { MGLLightAnchorMap, "map" }, + { MGLLightAnchorViewport, "viewport" }, + }); + +} + +NS_INLINE MGLTransition MGLTransitionFromOptions(const mbgl::style::TransitionOptions& options) { + MGLTransition transition; + transition.duration = MGLTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); + transition.delay = MGLTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); + + return transition; +} + +NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition transition) { + mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; + return options; +} + +@interface MGLLight() + +@end + +@implementation MGLLight + +- (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight +{ + if (self = [super init]) { + auto anchor = mbglLight->getAnchor(); + MGLStyleValue *anchorStyleValue; + if (anchor.isUndefined()) { + mbgl::style::PropertyValue defaultAnchor = mbglLight->getDefaultAnchor(); + anchorStyleValue = MGLStyleValueTransformer().toEnumStyleValue(defaultAnchor); + } else { + anchorStyleValue = MGLStyleValueTransformer().toEnumStyleValue(anchor); + } + + NSAssert([anchorStyleValue isKindOfClass:[MGLConstantStyleValue class]], @"Anchor isn’t a constant."); + NSValue *anchorValue = ((MGLConstantStyleValue *)anchorStyleValue).rawValue; + _anchor = [anchorValue MGLLightAnchorValue]; + + _anchorTransition = MGLTransitionFromOptions(mbglLight->getAnchorTransition()); + + auto positionValue = mbglLight->getPosition(); + if (positionValue.isUndefined()) { + _position = MGLStyleValueTransformer().toStyleValue(mbglLight->getDefaultPosition()); + } else { + _position = MGLStyleValueTransformer().toStyleValue(positionValue); + } + + _positionTransiton = MGLTransitionFromOptions(mbglLight->getPositionTransition()); + + auto colorValue = mbglLight->getColor(); + if (colorValue.isUndefined()) { + _color = MGLStyleValueTransformer().toStyleValue(mbglLight->getDefaultColor()); + } else { + _color = MGLStyleValueTransformer().toStyleValue(colorValue); + } + + _colorTransiton = MGLTransitionFromOptions(mbglLight->getColorTransition()); + + auto intensityValue = mbglLight->getIntensity(); + if (intensityValue.isUndefined()) { + _intensity = MGLStyleValueTransformer().toStyleValue(mbglLight->getDefaultIntensity()); + } else { + _intensity = MGLStyleValueTransformer().toStyleValue(intensityValue); + } + + _intensityTransition = MGLTransitionFromOptions(mbglLight->getIntensityTransition()); + } + + return self; +} + +- (mbgl::style::Light)mbglLight +{ + mbgl::style::Light mbglLight; + + MGLStyleValue *anchorType = [MGLStyleValue valueWithRawValue:[NSValue valueWithMGLLightAnchor:self.anchor]]; + auto anchor = MGLStyleValueTransformer().toEnumPropertyValue(anchorType); + mbglLight.setAnchor(anchor); + + + mbglLight.setAnchorTransition(MGLOptionsFromTransition(self.anchorTransition)); + + auto position = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.position); + mbglLight.setPosition(position); + + mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransiton)); + + auto color = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.color); + mbglLight.setColor(color); + + mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransiton)); + + auto intensity = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.intensity); + mbglLight.setIntensity(intensity); + + mbglLight.setIntensityTransition(MGLOptionsFromTransition(self.intensityTransition)); + + return mbglLight; +} + +@end diff --git a/platform/darwin/src/MGLLight_Private.h b/platform/darwin/src/MGLLight_Private.h new file mode 100644 index 0000000000..dbc29c1eff --- /dev/null +++ b/platform/darwin/src/MGLLight_Private.h @@ -0,0 +1,23 @@ +#import + +#import "MGLLight.h" + +namespace mbgl { + namespace style { + class Light; + } +} + +@interface MGLLight (Private) + +/** + Initializes and returns a `MGLLight` associated with a style's light. + */ +- (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight; + +/** + Returns an `mbgl::style::Light` representation of the `MGLLight`. + */ +- (mbgl::style::Light)mbglLight; + +@end diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 26434eb492..08c6c047f1 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -6,6 +6,7 @@ #import "MGLTypes.h" @class MGLSource; +@class MGLLight; NS_ASSUME_NONNULL_BEGIN @@ -564,6 +565,14 @@ MGL_EXPORT */ - (void)removeImageForName:(NSString *)name; + +#pragma mark Managing the Style's Light + +/** + Provides global light source for the style. + */ +@property (nonatomic, strong) MGLLight *light; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index af02c31b6d..eb838085d7 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -14,6 +14,7 @@ #import "MGLStyle_Private.h" #import "MGLStyleLayer_Private.h" #import "MGLSource_Private.h" +#import "MGLLight_Private.h" #import "NSDate+MGLAdditions.h" @@ -28,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -584,6 +586,21 @@ static NSURL *MGLStyleURL_emerald; return transition; } +#pragma mark Style light + +- (void)setLight:(MGLLight *)light +{ + std::unique_ptr mbglLight = std::make_unique([light mbglLight]); + self.mapView.mbglMap->setLight(std::move(mbglLight)); +} + +- (MGLLight *)light +{ + auto mbglLight = self.mapView.mbglMap->getLight(); + MGLLight *light = [[MGLLight alloc] initWithMBGLLight:mbglLight]; + return light; +} + - (NSString *)description { return [NSString stringWithFormat:@"<%@: %p; name = %@, URL = %@>", diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index 263b54d7e5..2155c657bd 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -3,11 +3,13 @@ #import "MGLStyleValue.h" #import "NSValue+MGLStyleAttributeAdditions.h" +#import "NSValue+MGLAdditions.h" #import "MGLTypes.h" #import "MGLConversion.h" #include #include +#import #import @@ -415,6 +417,12 @@ private: // Private utilities for converting from mgl to mbgl values mbglValue.push_back(mbglElement); } } + + void getMBGLValue(NSValue *rawValue, mbgl::style::Position &mbglValue) { + auto spherical = rawValue.mgl_lightPositionArrayValue; + mbgl::style::Position position(spherical); + mbglValue = position; + } // Enumerations template spherical = mbglStopValue.getSpherical(); + MGLSphericalPosition position = MGLSphericalPositionMake(spherical[0], spherical[1], spherical[2]); + return [NSValue valueWithMGLSphericalPosition:position]; + } // Enumerations template diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index c06fd8b0e7..16f510b5a6 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -1,4 +1,5 @@ #import +#import #import "MGLFoundation.h" diff --git a/platform/darwin/src/NSValue+MGLAdditions.h b/platform/darwin/src/NSValue+MGLAdditions.h index e6755021d0..0aaa2a337a 100644 --- a/platform/darwin/src/NSValue+MGLAdditions.h +++ b/platform/darwin/src/NSValue+MGLAdditions.h @@ -1,6 +1,7 @@ #import #import "MGLGeometry.h" +#import "MGLLight.h" #import "MGLOfflinePack.h" #import "MGLTypes.h" @@ -87,6 +88,34 @@ NS_ASSUME_NONNULL_BEGIN */ @property (readonly) MGLTransition MGLTransitionValue; +/** + Creates a new value object containing the given `MGLSphericalPosition` + structure. + + @param lightPosition The value for the new object. + @return A new value object that contains the light position information. + */ ++ (instancetype)valueWithMGLSphericalPosition:(MGLSphericalPosition)lightPosition; + +/** + The `MGLSphericalPosition` structure representation of the value. + */ +@property (readonly) MGLSphericalPosition MGLSphericalPositionValue; + +/** + Creates a new value object containing the given `MGLLightAnchor` + enum. + + @param lightAnchor The value for the new object. + @return A new value object that contains the light anchor information. + */ ++ (NSValue *)valueWithMGLLightAnchor:(MGLLightAnchor)lightAnchor; + +/** + The `MGLLightAnchor` enum representation of the value. + */ +@property (readonly) MGLLightAnchor MGLLightAnchorValue; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSValue+MGLAdditions.m b/platform/darwin/src/NSValue+MGLAdditions.m index a95ef23941..ef894f0eb4 100644 --- a/platform/darwin/src/NSValue+MGLAdditions.m +++ b/platform/darwin/src/NSValue+MGLAdditions.m @@ -58,4 +58,27 @@ return transition; } ++ (NSValue *)valueWithMGLSphericalPosition:(MGLSphericalPosition)lightPosition +{ + return [NSValue value:&lightPosition withObjCType:@encode(MGLSphericalPosition)]; +} + +- (MGLSphericalPosition)MGLSphericalPositionValue +{ + MGLSphericalPosition lightPosition; + [self getValue:&lightPosition]; + return lightPosition; +} + ++ (NSValue *)valueWithMGLLightAnchor:(MGLLightAnchor)lightAnchor { + return [NSValue value:&lightAnchor withObjCType:@encode(MGLLightAnchor)]; +} + +- (MGLLightAnchor)MGLLightAnchorValue +{ + MGLLightAnchor achorType; + [self getValue:&achorType]; + return achorType; +} + @end diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h index 60c1ee4075..0f1e511694 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h @@ -9,5 +9,6 @@ - (std::array)mgl_offsetArrayValue; - (std::array)mgl_paddingArrayValue; +- (std::array)mgl_lightPositionArrayValue; @end diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm index e66145aec1..a41950b6b3 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm @@ -1,5 +1,5 @@ #import "NSValue+MGLStyleAttributeAdditions.h" - +#import "MGLLight.h" #if TARGET_OS_IPHONE #import #define MGLEdgeInsets UIEdgeInsets @@ -61,4 +61,17 @@ }; } +- (std::array)mgl_lightPositionArrayValue +{ + NSAssert(strcmp(self.objCType, @encode(MGLSphericalPosition)) == 0, @"Value does not represent an MGLSphericalPosition"); + MGLSphericalPosition lightPosition; + [self getValue:&lightPosition]; + // Style specification defines padding in clockwise order: top, right, bottom, left. + return { + static_cast(lightPosition.radial), + static_cast(lightPosition.azimuthal), + static_cast(lightPosition.polar), + }; +} + @end -- cgit v1.2.1 From a57e9bc41093eb8f028dcab3593c3921d887bdc0 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Tue, 23 May 2017 12:32:18 -0400 Subject: [ios,macos] multipolygon coordinate (#8713) * [ios] MGLMultiPolygon's coordinate property implemented * [ios,macos] Add polylabalel to project config * [ios,macos] Change coordinate property for MGLPolyline,MGLPolygon,MGLMultiPolygon * [macos] Change project configuration to support polilabel * [ios,macos] Add MGLLocationCoordinate2DFromPoint * [ios, macos] Update changelogs * [ios, macos] remove unnecesary variables * [ios, macos] Add radians conversions * [ios, macos] Add coordinate calc to MGLPolyline * [ios, macos] Move radian fuctions to MGLGeometry_Private.h * [ios, macos] Fix code style * [ios, macos] Fix code indentation * [ios, macos] Fix radian per meters constant * [ios, macos] Add test scenarios to testPolyline * [ios, macos] Fix test accuracy --- platform/darwin/src/MGLGeometry_Private.h | 64 ++++++++++++++++++++++++++++++ platform/darwin/src/MGLPolygon.mm | 20 +++++++++- platform/darwin/src/MGLPolyline.mm | 65 +++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index 3e029e8ee0..7ad8314a79 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -8,6 +8,26 @@ #import #import +typedef double MGLLocationRadians; +typedef double MGLRadianDistance; +typedef double MGLRadianDirection; + +/** Defines the coordinate by a `MGLRadianCoordinate2D`. */ +typedef struct MGLRadianCoordinate2D { + MGLLocationRadians latitude; + MGLLocationRadians longitude; +} MGLRadianCoordinate2D; + +/** + Creates a new `MGLRadianCoordinate2D` from the given latitudinal and longitudinal. + */ +NS_INLINE MGLRadianCoordinate2D MGLRadianCoordinate2DMake(MGLLocationRadians latitude, MGLLocationRadians longitude) { + MGLRadianCoordinate2D radianCoordinate; + radianCoordinate.latitude = latitude; + radianCoordinate.longitude = longitude; + return radianCoordinate; +} + /// Returns the smallest rectangle that contains both the given rectangle and /// the given point. CGRect MGLExtendRect(CGRect rect, CGPoint point); @@ -18,6 +38,10 @@ NS_INLINE mbgl::Point MGLPointFromLocationCoordinate2D(CLLocationCoordin return mbgl::Point(coordinate.longitude, coordinate.latitude); } +NS_INLINE CLLocationCoordinate2D MGLLocationCoordinate2DFromPoint(mbgl::Point point) { + return CLLocationCoordinate2DMake(point.y, point.x); +} + NS_INLINE CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) { return CLLocationCoordinate2DMake(latLng.latitude(), latLng.longitude()); } @@ -59,3 +83,43 @@ CLLocationDistance MGLAltitudeForZoomLevel(double zoomLevel, CGFloat pitch, CLLo @param size The size of the viewport. @return A zero-based zoom level. */ double MGLZoomLevelForAltitude(CLLocationDistance altitude, CGFloat pitch, CLLocationDegrees latitude, CGSize size); + +/** Returns MGLRadianCoordinate2D, converted from CLLocationCoordinate2D. */ +NS_INLINE MGLRadianCoordinate2D MGLRadianCoordinateFromLocationCoordinate(CLLocationCoordinate2D locationCoordinate) { + return MGLRadianCoordinate2DMake(MGLRadiansFromDegrees(locationCoordinate.latitude), + MGLRadiansFromDegrees(locationCoordinate.longitude)); +} + +/* + Returns the distance in radians given two coordinates. + */ +NS_INLINE MGLRadianDistance MGLDistanceBetweenRadianCoordinates(MGLRadianCoordinate2D from, MGLRadianCoordinate2D to) +{ + double a = pow(sin((to.latitude - from.latitude) / 2), 2) + + pow(sin((to.longitude - from.longitude) / 2), 2) * cos(from.latitude) * cos(to.latitude); + + return 2 * atan2(sqrt(a), sqrt(1 - a)); +} + +/* + Returns direction in radians given two coordinates. + */ +NS_INLINE MGLRadianDirection MGLRadianCoordinatesDirection(MGLRadianCoordinate2D from, MGLRadianCoordinate2D to) { + double a = sin(to.longitude - from.longitude) * cos(to.latitude); + double b = cos(from.latitude) * sin(to.latitude) + - sin(from.latitude) * cos(to.latitude) * cos(to.longitude - from.longitude); + return atan2(a, b); +} + +/* + Returns coordinate at a given distance and direction away from coordinate. + */ +NS_INLINE MGLRadianCoordinate2D MGLRadianCoordinateAtDistanceFacingDirection(MGLRadianCoordinate2D coordinate, + MGLRadianDistance distance, + MGLRadianDirection direction) { + double otherLatitude = asin(sin(coordinate.latitude) * cos(distance) + + cos(coordinate.latitude) * sin(distance) * cos(direction)); + double otherLongitude = coordinate.longitude + atan2(sin(direction) * sin(distance) * cos(coordinate.latitude), + cos(distance) - sin(coordinate.latitude) * sin(otherLatitude)); + return MGLRadianCoordinate2DMake(otherLatitude, otherLongitude); +} diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm index ceafe873bf..d966ff13ce 100644 --- a/platform/darwin/src/MGLPolygon.mm +++ b/platform/darwin/src/MGLPolygon.mm @@ -6,6 +6,7 @@ #import "MGLPolygon+MGLAdditions.h" #import +#import @implementation MGLPolygon @@ -54,6 +55,13 @@ return [super hash] + [[self geoJSONDictionary] hash]; } +- (CLLocationCoordinate2D)coordinate { + // pole of inaccessibility + auto poi = mapbox::polylabel([self polygon]); + + return MGLLocationCoordinate2DFromPoint(poi); +} + - (mbgl::LinearRing)ring { NSUInteger count = self.pointCount; CLLocationCoordinate2D *coordinates = self.coordinates; @@ -155,11 +163,17 @@ return hash; } +- (CLLocationCoordinate2D)coordinate { + MGLPolygon *firstPolygon = self.polygons.firstObject; + + return firstPolygon.coordinate; +} + - (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds { return MGLCoordinateBoundsIntersectsCoordinateBounds(_overlayBounds, overlayBounds); } -- (mbgl::Geometry)geometryObject { +- (mbgl::MultiPolygon)multiPolygon { mbgl::MultiPolygon multiPolygon; multiPolygon.reserve(self.polygons.count); for (MGLPolygon *polygon in self.polygons) { @@ -173,6 +187,10 @@ return multiPolygon; } +- (mbgl::Geometry)geometryObject { + return [self multiPolygon]; +} + - (NSDictionary *)geoJSONDictionary { NSMutableArray *coordinates = [[NSMutableArray alloc] initWithCapacity:self.polygons.count]; for (MGLPolygonFeature *feature in self.polygons) { diff --git a/platform/darwin/src/MGLPolyline.mm b/platform/darwin/src/MGLPolyline.mm index ae4fbe61de..fd75dc2795 100644 --- a/platform/darwin/src/MGLPolyline.mm +++ b/platform/darwin/src/MGLPolyline.mm @@ -6,6 +6,7 @@ #import "MGLPolyline+MGLAdditions.h" #import +#import @implementation MGLPolyline @@ -52,6 +53,61 @@ return self == other || ([other isKindOfClass:[MGLPolyline class]] && [super isEqual:other]); } +- (CLLocationCoordinate2D)coordinate { + NSUInteger count = self.pointCount; + NSAssert(count > 0, @"Polyline must have coordinates"); + + CLLocationCoordinate2D *coordinates = self.coordinates; + CLLocationDistance middle = [self length] / 2.0; + CLLocationDistance traveled = 0.0; + + if (count > 1 || middle > traveled) { + for (NSUInteger i = 0; i < count; i++) { + + MGLRadianCoordinate2D from = MGLRadianCoordinateFromLocationCoordinate(coordinates[i]); + MGLRadianCoordinate2D to = MGLRadianCoordinateFromLocationCoordinate(coordinates[i + 1]); + + if (traveled >= middle) { + double overshoot = middle - traveled; + if (overshoot == 0) { + return coordinates[i]; + } + to = MGLRadianCoordinateFromLocationCoordinate(coordinates[i - 1]); + CLLocationDirection direction = [self direction:from to:to] - 180; + MGLRadianCoordinate2D otherCoordinate = MGLRadianCoordinateAtDistanceFacingDirection(from, + overshoot/mbgl::util::EARTH_RADIUS_M, + MGLRadiansFromDegrees(direction)); + return CLLocationCoordinate2DMake(MGLDegreesFromRadians(otherCoordinate.latitude), + MGLDegreesFromRadians(otherCoordinate.longitude)); + } + + traveled += (MGLDistanceBetweenRadianCoordinates(from, to) * mbgl::util::EARTH_RADIUS_M); + + } + } + + return coordinates[count - 1]; +} + +- (CLLocationDistance)length +{ + CLLocationDistance length = 0.0; + + NSUInteger count = self.pointCount; + CLLocationCoordinate2D *coordinates = self.coordinates; + + for (NSUInteger i = 0; i < count - 1; i++) { + length += (MGLDistanceBetweenRadianCoordinates(MGLRadianCoordinateFromLocationCoordinate(coordinates[i]), MGLRadianCoordinateFromLocationCoordinate(coordinates[i + 1])) * mbgl::util::EARTH_RADIUS_M); + } + + return length; +} + +- (CLLocationDirection)direction:(MGLRadianCoordinate2D)from to:(MGLRadianCoordinate2D)to +{ + return MGLDegreesFromRadians(MGLRadianCoordinatesDirection(from, to)); +} + @end @interface MGLMultiPolyline () @@ -114,6 +170,15 @@ return hash; } +- (CLLocationCoordinate2D)coordinate { + MGLPolyline *polyline = self.polylines.firstObject; + CLLocationCoordinate2D *coordinates = polyline.coordinates; + NSAssert([polyline pointCount] > 0, @"Polyline must have coordinates"); + CLLocationCoordinate2D firstCoordinate = coordinates[0]; + + return firstCoordinate; +} + - (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds { return MGLCoordinateBoundsIntersectsCoordinateBounds(_overlayBounds, overlayBounds); } -- cgit v1.2.1 From 9b11bb98fa855da9d845ed01e59451943bb29af4 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 23 May 2017 13:24:16 -0400 Subject: [ios] Fallback to Mapbox.bundle as the framework bundle (#9074) Fixes an issue where localizations could not be found when using static builds. Throws exception if our bundle can't be found. --- platform/darwin/src/NSBundle+MGLAdditions.h | 4 ---- platform/darwin/src/NSBundle+MGLAdditions.m | 28 ++++++++++++---------------- 2 files changed, 12 insertions(+), 20 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/NSBundle+MGLAdditions.h b/platform/darwin/src/NSBundle+MGLAdditions.h index 1fc9e8b896..df70d23923 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.h +++ b/platform/darwin/src/NSBundle+MGLAdditions.h @@ -36,10 +36,6 @@ NS_ASSUME_NONNULL_BEGIN + (nullable NS_DICTIONARY_OF(NSString *, id) *)mgl_frameworkInfoDictionary; -/// The relative path to the directory containing the SDK’s resource files, or -/// `nil` if the files are located directly within the bundle’s root directory. -@property (readonly, copy, nullable) NSString *mgl_resourcesDirectory; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSBundle+MGLAdditions.m b/platform/darwin/src/NSBundle+MGLAdditions.m index 76d9cc0db7..ad122831ba 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.m +++ b/platform/darwin/src/NSBundle+MGLAdditions.m @@ -6,12 +6,19 @@ + (instancetype)mgl_frameworkBundle { NSBundle *bundle = [self bundleForClass:[MGLAccountManager class]]; - if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"] && !bundle.mgl_resourcesDirectory) { + + if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"]) { // For static frameworks, the bundle is the containing application - // bundle but the resources are still in the framework bundle. - bundle = [NSBundle bundleWithPath:[bundle.privateFrameworksPath - stringByAppendingPathComponent:@"Mapbox.framework"]]; + // bundle but the resources are in Mapbox.bundle. + NSString *bundlePath = [bundle pathForResource:@"Mapbox" ofType:@"bundle"]; + if (bundlePath) { + bundle = [self bundleWithPath:bundlePath]; + } else { + [NSException raise:@"MGLBundleNotFoundException" format: + @"The Mapbox framework bundle could not be found. If using the Mapbox iOS SDK as a static framework, make sure that Mapbox.bundle is copied into the root of the app bundle."]; + } } + return bundle; } @@ -21,18 +28,7 @@ + (nullable NS_DICTIONARY_OF(NSString *, id) *)mgl_frameworkInfoDictionary { NSBundle *bundle = self.mgl_frameworkBundle; - if (bundle.mgl_resourcesDirectory) { - NSString *infoPlistPath = [bundle pathForResource:@"Info" - ofType:@"plist" - inDirectory:bundle.mgl_resourcesDirectory]; - return [NSDictionary dictionaryWithContentsOfFile:infoPlistPath]; - } else { - return bundle.infoDictionary; - } -} - -- (NSString *)mgl_resourcesDirectory { - return [self pathForResource:@"Mapbox" ofType:@"bundle"] ? @"Mapbox.bundle" : nil; + return bundle.infoDictionary; } @end -- cgit v1.2.1 From e1431f9085153f7afb33ee169289ff46d38fe209 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Wed, 24 May 2017 12:20:58 -0400 Subject: [ios, macos] Fix MGLLight.achor to accept style functions --- platform/darwin/src/MGLLight.h | 4 ++-- platform/darwin/src/MGLLight.mm | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h index d9a22d60fa..ef9811bd33 100644 --- a/platform/darwin/src/MGLLight.h +++ b/platform/darwin/src/MGLLight.h @@ -60,7 +60,7 @@ MGL_EXPORT href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-anchor">anchor light property in the Mapbox Style Specification. */ -@property (nonatomic) MGLLightAnchor anchor; +@property (nonatomic) MGLStyleValue *anchor; /** Values describing animated transitions to `anchor` property. @@ -75,7 +75,7 @@ MGL_EXPORT href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-position">position light property in the Mapbox Style Specification. */ -@property (nonatomic) MGLStyleValue * position; +@property (nonatomic) MGLStyleValue *position; /** Values describing animated transitions to `position` property. diff --git a/platform/darwin/src/MGLLight.mm b/platform/darwin/src/MGLLight.mm index 02d55e76ed..262fad3b07 100644 --- a/platform/darwin/src/MGLLight.mm +++ b/platform/darwin/src/MGLLight.mm @@ -48,9 +48,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition anchorStyleValue = MGLStyleValueTransformer().toEnumStyleValue(anchor); } - NSAssert([anchorStyleValue isKindOfClass:[MGLConstantStyleValue class]], @"Anchor isn’t a constant."); - NSValue *anchorValue = ((MGLConstantStyleValue *)anchorStyleValue).rawValue; - _anchor = [anchorValue MGLLightAnchorValue]; + _anchor = anchorStyleValue; _anchorTransition = MGLTransitionFromOptions(mbglLight->getAnchorTransition()); @@ -89,11 +87,9 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition { mbgl::style::Light mbglLight; - MGLStyleValue *anchorType = [MGLStyleValue valueWithRawValue:[NSValue valueWithMGLLightAnchor:self.anchor]]; - auto anchor = MGLStyleValueTransformer().toEnumPropertyValue(anchorType); + auto anchor = MGLStyleValueTransformer().toEnumPropertyValue(self.anchor); mbglLight.setAnchor(anchor); - mbglLight.setAnchorTransition(MGLOptionsFromTransition(self.anchorTransition)); auto position = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.position); -- cgit v1.2.1 From a39116a552bbb7b77f2946b5931944c7065d818e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 30 May 2017 15:14:00 -0700 Subject: =?UTF-8?q?Migrate=20to=20GL=20JS=E2=80=93powered=20feedback=20for?= =?UTF-8?q?m=20(#9078)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ios, macos] Updated feedback URL * [ios, macos] Add referrer, heading, pitch to feedback URL * [ios, macos] Updated changelogs for feedback changes * [ios] Vary referrer by platform --- platform/darwin/src/MGLAttributionInfo.mm | 31 +++++++++++++++++++++--- platform/darwin/src/MGLAttributionInfo_Private.h | 18 ++++++++++++++ platform/darwin/src/MGLOfflineStorage.mm | 14 +++-------- platform/darwin/src/NSBundle+MGLAdditions.h | 2 ++ platform/darwin/src/NSBundle+MGLAdditions.m | 9 +++++++ 5 files changed, 59 insertions(+), 15 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index 7583244491..770aeb25e7 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -6,8 +6,10 @@ #import #endif +#import "MGLAccountManager.h" #import "MGLMapCamera.h" #import "NSArray+MGLAdditions.h" +#import "NSBundle+MGLAdditions.h" #import "NSString+MGLAdditions.h" #include @@ -126,13 +128,34 @@ } - (nullable NSURL *)feedbackURLAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel { + return [self feedbackURLForStyleURL:nil atCenterCoordinate:centerCoordinate zoomLevel:zoomLevel direction:0 pitch:0]; +} + +- (nullable NSURL *)feedbackURLForStyleURL:(nullable NSURL *)styleURL atCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction pitch:(CGFloat)pitch { if (!self.feedbackLink) { return nil; } - - NSURLComponents *components = [NSURLComponents componentsWithURL:self.URL resolvingAgainstBaseURL:NO]; - components.fragment = [NSString stringWithFormat:@"/%.5f/%.5f/%i", - centerCoordinate.longitude, centerCoordinate.latitude, (int)round(zoomLevel + 1)]; + + NSURLComponents *components = [NSURLComponents componentsWithString:@"https://www.mapbox.com/feedback/"]; + components.fragment = [NSString stringWithFormat:@"/%.5f/%.5f/%.2f/%.1f/%i", + centerCoordinate.longitude, centerCoordinate.latitude, zoomLevel, + direction, (int)round(pitch)]; + + NSURLQueryItem *referrerQueryItem = [NSURLQueryItem queryItemWithName:@"referrer" + value:[NSBundle mgl_applicationBundleIdentifier]]; + NSMutableArray *queryItems = [NSMutableArray arrayWithObject:referrerQueryItem]; + if ([styleURL.scheme isEqualToString:@"mapbox"] && [styleURL.host isEqualToString:@"styles"]) { + NSArray *stylePathComponents = styleURL.pathComponents; + if (stylePathComponents.count >= 3) { + [queryItems addObjectsFromArray:@[ + [NSURLQueryItem queryItemWithName:@"owner" value:stylePathComponents[1]], + [NSURLQueryItem queryItemWithName:@"id" value:stylePathComponents[2]], + [NSURLQueryItem queryItemWithName:@"access_token" value:[MGLAccountManager accessToken]], + ]]; + } + } + components.queryItems = queryItems; + return components.URL; } diff --git a/platform/darwin/src/MGLAttributionInfo_Private.h b/platform/darwin/src/MGLAttributionInfo_Private.h index 08bc6bfc4d..c639752ac3 100644 --- a/platform/darwin/src/MGLAttributionInfo_Private.h +++ b/platform/darwin/src/MGLAttributionInfo_Private.h @@ -20,6 +20,24 @@ NS_ASSUME_NONNULL_BEGIN + (NSAttributedString *)attributedStringForAttributionInfos:(NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos; +/** + Returns a copy of the `URL` property modified to account for the given style + URL, center coordinate, and zoom level. + + @param styleURL The map’s style URL. + @param centerCoordinate The map’s center coordinate. + @param zoomLevel The map’s zoom level. See the `MGLMapView.zoomLevel` property + for more information. + @param direction The heading of the map, measured in degrees clockwise from + true north. + @param pitch Pitch toward the horizon measured in degrees, with 0 degrees + resulting in a two-dimensional map. + @return A modified URL containing a fragment that points to the specified + viewport. If the `feedbackLink` property is set to `NO`, this method returns + `nil`. + */ +- (nullable NSURL *)feedbackURLForStyleURL:(nullable NSURL *)styleURL atCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction pitch:(CGFloat)pitch; + @end @interface NSMutableArray (MGLAttributionInfoAdditions) diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 195ef3c36a..81774ad3cb 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -7,6 +7,7 @@ #import "MGLOfflinePack_Private.h" #import "MGLOfflineRegion_Private.h" #import "MGLTilePyramidOfflineRegion.h" +#import "NSBundle+MGLAdditions.h" #import "NSValue+MGLAdditions.h" #include @@ -132,7 +133,7 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK appropriateForURL:nil create:YES error:nil]; - NSString *bundleIdentifier = [self bundleIdentifier]; + NSString *bundleIdentifier = [NSBundle mgl_applicationBundleIdentifier]; if (!bundleIdentifier) { // There’s no main bundle identifier when running in a unit test bundle. bundleIdentifier = [NSBundle bundleForClass:self].bundleIdentifier; @@ -166,7 +167,7 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK NSString *legacyCachePath = [legacyPaths.firstObject stringByAppendingPathComponent:MGLOfflineStorageFileName3_2_0_beta_1]; #elif TARGET_OS_MAC // ~/Library/Caches/tld.app.bundle.id/offline.db - NSString *bundleIdentifier = [self bundleIdentifier]; + NSString *bundleIdentifier = [NSBundle mgl_applicationBundleIdentifier]; NSURL *legacyCacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil @@ -219,15 +220,6 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK return self; } -+ (NSString *)bundleIdentifier { - NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier; - if (!bundleIdentifier) { - // There’s no main bundle identifier when running in a unit test bundle. - bundleIdentifier = [NSBundle bundleForClass:self].bundleIdentifier; - } - return bundleIdentifier; -} - - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [[MGLNetworkConfiguration sharedManager] removeObserver:self forKeyPath:@"apiBaseURL"]; diff --git a/platform/darwin/src/NSBundle+MGLAdditions.h b/platform/darwin/src/NSBundle+MGLAdditions.h index df70d23923..ad5e9d5369 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.h +++ b/platform/darwin/src/NSBundle+MGLAdditions.h @@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN + (nullable NS_DICTIONARY_OF(NSString *, id) *)mgl_frameworkInfoDictionary; ++ (nullable NSString *)mgl_applicationBundleIdentifier; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSBundle+MGLAdditions.m b/platform/darwin/src/NSBundle+MGLAdditions.m index ad122831ba..f383a50300 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.m +++ b/platform/darwin/src/NSBundle+MGLAdditions.m @@ -31,4 +31,13 @@ return bundle.infoDictionary; } ++ (nullable NSString *)mgl_applicationBundleIdentifier { + NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier; + if (!bundleIdentifier) { + // There’s no main bundle identifier when running in a unit test bundle. + bundleIdentifier = [NSBundle bundleForClass:[MGLAccountManager class]].bundleIdentifier; + } + return bundleIdentifier; +} + @end -- cgit v1.2.1 From 87a05b29c9f09ad36ec01b71f78ba5e6ad3aa88b Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Mon, 12 Jun 2017 11:30:53 -0400 Subject: [ios, macos] Fix MGLSphericalPosition.radial misleading type. --- platform/darwin/src/MGLLight.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h index ef9811bd33..6dd24712e2 100644 --- a/platform/darwin/src/MGLLight.h +++ b/platform/darwin/src/MGLLight.h @@ -20,7 +20,7 @@ typedef NS_ENUM(NSUInteger, MGLLightAnchor) { */ typedef struct MGLSphericalPosition { /** Distance from the center of the base of an object to its light. */ - CLLocationDistance radial; + CGFloat radial; /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, and degrees proceed clockwise). */ -- cgit v1.2.1 From df3af9738962d377b0b269347a9d91f2173da7e5 Mon Sep 17 00:00:00 2001 From: Jordan Kiley Date: Wed, 14 Jun 2017 11:26:34 -0700 Subject: [ios, macos] Revised descriptions for abstract classes (#9095) Addresses https://github.com/mapbox/mapbox-gl-native/issues/8635 --- platform/darwin/src/MGLForegroundStyleLayer.h | 7 ++++--- platform/darwin/src/MGLMultiPoint.h | 5 +++-- platform/darwin/src/MGLShape.h | 10 +++++----- platform/darwin/src/MGLSource.h | 7 ++++--- platform/darwin/src/MGLStyleLayer.h | 8 ++++---- platform/darwin/src/MGLStyleValue.h | 9 ++++----- platform/darwin/src/MGLTileSource.h | 6 +++--- platform/darwin/src/MGLVectorStyleLayer.h | 8 ++++---- 8 files changed, 31 insertions(+), 29 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLForegroundStyleLayer.h b/platform/darwin/src/MGLForegroundStyleLayer.h index 16a973630e..bcd323fb99 100644 --- a/platform/darwin/src/MGLForegroundStyleLayer.h +++ b/platform/darwin/src/MGLForegroundStyleLayer.h @@ -11,9 +11,10 @@ NS_ASSUME_NONNULL_BEGIN `MGLForegroundStyleLayer` is an abstract superclass for style layers whose content is defined by an `MGLSource` object. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of `MGLRasterStyleLayer` - and the concrete subclasses of `MGLVectorStyleLayer`. + Create instances of `MGLRasterStyleLayer` and the concrete subclasses of + `MGLVectorStyleLayer` in order to use `MGLForegroundStyleLayer`'s methods. + Do not create instances of `MGLForegroundStyleLayer` directly, and do not + create your own subclasses of this class. */ MGL_EXPORT @interface MGLForegroundStyleLayer : MGLStyleLayer diff --git a/platform/darwin/src/MGLMultiPoint.h b/platform/darwin/src/MGLMultiPoint.h index 429bbdb22d..ee9eb530a4 100644 --- a/platform/darwin/src/MGLMultiPoint.h +++ b/platform/darwin/src/MGLMultiPoint.h @@ -10,8 +10,9 @@ NS_ASSUME_NONNULL_BEGIN The `MGLMultiPoint` class is an abstract superclass used to define shapes composed of multiple vertices. - You do not create instances of this class directly. Instead, you create - instances of the `MGLPolyline` or `MGLPolygon` classes. However, you can use + Create instances of `MGLPolyline` or `MGLPolygon` in order to use + properties of `MGLMultiPoint`. Do not create instances of `MGLMultiPoint` + directly and do not create your own subclasses of this class. You can use the method and properties of this class to access information about the vertices of the line or polygon. diff --git a/platform/darwin/src/MGLShape.h b/platform/darwin/src/MGLShape.h index bd8b6152d2..e965710552 100644 --- a/platform/darwin/src/MGLShape.h +++ b/platform/darwin/src/MGLShape.h @@ -10,11 +10,11 @@ NS_ASSUME_NONNULL_BEGIN constitute the content of a map – not only the overlays atop the map, but also the content that forms the base map. - You do not create instances of this class directly or create subclasses of this - class. Instead, you create instances of `MGLPointAnnotation`, - `MGLPointCollection`, `MGLPolyline`, `MGLMultiPolyline`, `MGLPolygon`, - `MGLMultiPolygon`, or `MGLShapeCollection`. The shape classes correspond to the - Geometry object + Create instances of `MGLPointAnnotation`, `MGLPointCollection`, `MGLPolyline`, + `MGLMultiPolyline`, `MGLPolygon`, `MGLMultiPolygon`, or `MGLShapeCollection` in + order to use `MGLShape`'s methods. Do not create instances of `MGLShape` directly, + and do not create your own subclasses of this class. The shape classes correspond + to the Geometry object types in the GeoJSON standard, but some have nonstandard names for backwards compatibility. diff --git a/platform/darwin/src/MGLSource.h b/platform/darwin/src/MGLSource.h index 8bf48907cc..151363104e 100644 --- a/platform/darwin/src/MGLSource.h +++ b/platform/darwin/src/MGLSource.h @@ -16,9 +16,10 @@ NS_ASSUME_NONNULL_BEGIN add and remove sources dynamically using methods such as `-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of `MGLShapeSource` and the - concrete subclasses of `MGLTileSource`, `MGLVectorSource` and `MGLRasterSource`. + Create instances of `MGLShapeSource` and the concrete subclasses of + `MGLTileSource`, `MGLVectorSource` and `MGLRasterSource` in order to use + `MGLMultiPoint`'s properties and methods. Do not create instances of `MGLSource` + directly, and do not create your own subclasses of this class. */ MGL_EXPORT @interface MGLSource : NSObject diff --git a/platform/darwin/src/MGLStyleLayer.h b/platform/darwin/src/MGLStyleLayer.h index 7d181667d6..b610a27607 100644 --- a/platform/darwin/src/MGLStyleLayer.h +++ b/platform/darwin/src/MGLStyleLayer.h @@ -14,10 +14,10 @@ NS_ASSUME_NONNULL_BEGIN `MGLStyleLayer` object, which you can use to refine the map’s appearance. You can also add and remove style layers dynamically. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of - `MGLBackgroundStyleLayer` and the concrete subclasses of - `MGLForegroundStyleLayer`. + Create instances of `MGLBackgroundStyleLayer` and the concrete subclasses of + `MGLForegroundStyleLayer` in order to use `MGLStyleLayer`'s properties and methods. + You do not create instances of `MGLStyleLayer` directly, and do not + create your own subclasses of this class. Do not add `MGLStyleLayer` objects to the `style` property of a `MGLMapView` before `-mapView:didFinishLoadingStyle:` is called. diff --git a/platform/darwin/src/MGLStyleValue.h b/platform/darwin/src/MGLStyleValue.h index 2bb3aca4f4..9c9b1dc4d1 100644 --- a/platform/darwin/src/MGLStyleValue.h +++ b/platform/darwin/src/MGLStyleValue.h @@ -239,11 +239,10 @@ MGL_EXPORT defined by an `MGLCameraStyleFunction`, `MGLSourceStyleFunction`, or `MGLCompositeStyleFunction` object. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, use one of the class factory methods in - `MGLStyleValue` to create instances of the following concrete subclasses: - `MGLCameraStyleFunction`, `MGLSourceStyleFunction`, and - `MGLCompositeStyleFunction`. + Create instances of `MGLCameraStyleFunction`, `MGLSourceStyleFunction`, and + `MGLCompositeStyleFunction` in order to use `MGLStyleFunction`'s methods. Do + not create instances of `MGLStyleFunction` directly, and do not create your + own subclasses of this class. The `MGLStyleFunction` class takes a generic parameter `T` that indicates the Foundation class being wrapped by this class. diff --git a/platform/darwin/src/MGLTileSource.h b/platform/darwin/src/MGLTileSource.h index 538b94037e..caeafcd2f6 100644 --- a/platform/darwin/src/MGLTileSource.h +++ b/platform/darwin/src/MGLTileSource.h @@ -140,9 +140,9 @@ typedef NS_ENUM(NSUInteger, MGLTileCoordinateSystem) { Mapbox-hosted tile set, view it in Mapbox Studio’s Tilesets editor. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of `MGLRasterSource` and - `MGLVectorSource`. + Create instances of `MGLRasterSource` and `MGLVectorSource` in order to use + `MGLTileSource`'s properties and methods. Do not create instances of `MGLTileSource` + directly, and do not create your own subclasses of this class. */ MGL_EXPORT @interface MGLTileSource : MGLSource diff --git a/platform/darwin/src/MGLVectorStyleLayer.h b/platform/darwin/src/MGLVectorStyleLayer.h index c6193e6046..e54a580aed 100644 --- a/platform/darwin/src/MGLVectorStyleLayer.h +++ b/platform/darwin/src/MGLVectorStyleLayer.h @@ -9,10 +9,10 @@ NS_ASSUME_NONNULL_BEGIN `MGLVectorStyleLayer` is an abstract superclass for style layers whose content is defined by an `MGLShapeSource` or `MGLVectorSource` object. - Do not create instances of this class directly, and do not create your own - subclasses of this class. Instead, create instances of the following concrete - subclasses: `MGLCircleStyleLayer`, `MGLFillStyleLayer`, `MGLLineStyleLayer`, - and `MGLSymbolStyleLayer`. + Create instances of `MGLCircleStyleLayer`, `MGLFillStyleLayer`, `MGLLineStyleLayer`, + and `MGLSymbolStyleLayer` in order to use `MGLVectorStyleLayer`'s properties and + methods. Do not create instances of `MGLVectorStyleLayer` directly, and do not + create your own subclasses of this class. */ MGL_EXPORT @interface MGLVectorStyleLayer : MGLForegroundStyleLayer -- cgit v1.2.1 From 67c09b18e491e66e2ba058498b8f3b44e49d0105 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Fri, 16 Jun 2017 06:41:51 -0700 Subject: MGLLight autogenerate scripts (#9260) * [ios, macos] Add the MGLLight generation templates * [ios, macos] Add MGLLight generation script * [ios, macos] Add the auto-generation script for MGLLight.mm * [ios, macos] Add the auto-generation script for MGLLightTest.mm * [core] Add const to Position constructor. * [ios, macos] Simplify MGLLightTest.mm autogenerate script. --- platform/darwin/src/MGLLight.h | 118 ++++++++++++++++++++++++++++-------- platform/darwin/src/MGLLight.h.ejs | 100 ++++++++++++++++++++++++++++++ platform/darwin/src/MGLLight.mm | 41 +++++++------ platform/darwin/src/MGLLight.mm.ejs | 114 ++++++++++++++++++++++++++++++++++ 4 files changed, 328 insertions(+), 45 deletions(-) create mode 100644 platform/darwin/src/MGLLight.h.ejs create mode 100644 platform/darwin/src/MGLLight.mm.ejs (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h index 6dd24712e2..55b789f043 100644 --- a/platform/darwin/src/MGLLight.h +++ b/platform/darwin/src/MGLLight.h @@ -1,3 +1,6 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. + #import #import "MGLFoundation.h" @@ -5,13 +8,19 @@ NS_ASSUME_NONNULL_BEGIN - -/** Options to specify extruded geometries are lit relative to the map or viewport. */ +/** + Whether extruded geometries are lit relative to the map or viewport. + */ typedef NS_ENUM(NSUInteger, MGLLightAnchor) { - /** The position of the light source is aligned to the rotation of the map. */ + /** + The position of the light source is aligned to the rotation of the map. + */ MGLLightAnchorMap, - /** The position of the light source is aligned to the rotation of the viewport. */ - MGLLightAnchorViewport + /** + The position of the light source is aligned to the rotation of the + viewport. + */ + MGLLightAnchorViewport, }; /** @@ -38,7 +47,7 @@ typedef struct MGLSphericalPosition { @return Returns a `MGLSphericalPosition` struct containing the position attributes. */ -NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CLLocationDistance radial, CLLocationDirection azimuthal, CLLocationDirection polar) { +NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocationDirection azimuthal, CLLocationDirection polar) { MGLSphericalPosition position; position.radial = radial; position.azimuthal = azimuthal; @@ -54,8 +63,17 @@ MGL_EXPORT @interface MGLLight : NSObject /** - `anchor` Whether extruded geometries are lit relative to the map or viewport. + Whether extruded geometries are lit relative to the map or viewport. + + The default value of this property is an `MGLStyleValue` object containing an + `NSValue` object containing `MGLLightAnchorViewport`. + You can set this property to an instance of: + + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of + `MGLInterpolationModeInterval` + This property corresponds to the anchor light property in the Mapbox Style Specification. @@ -63,14 +81,25 @@ MGL_EXPORT @property (nonatomic) MGLStyleValue *anchor; /** - Values describing animated transitions to `anchor` property. - */ -@property (nonatomic) MGLTransition anchorTransition; - - -/** - Position of the light source relative to lit (extruded) geometries. + Position of the `MGLLight` source relative to lit (extruded) geometries, in a + `MGLSphericalPosition` struct [radial coordinate, azimuthal angle, polar angle] + where radial indicates the distance from the center of the base of an object to + its light, azimuthal indicates the position of the light relative to 0° (0° + when `MGLLight.anchor` is set to `MGLLightAnchorViewport` corresponds to the + top of the viewport, or 0° when `MGLLight.anchor` is set to `MGLLightAnchorMap` + corresponds to due north, and degrees proceed clockwise), and polar indicates + the height of the light (from 0°, directly above, to 180°, directly below). + + The default value of this property is an `MGLStyleValue` object containing an + `MGLSphericalPosition` struct set to 1.15 radial, 210 azimuthal and 30 polar. + + You can set this property to an instance of: + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + This property corresponds to the position light property in the Mapbox Style Specification. @@ -78,48 +107,87 @@ MGL_EXPORT @property (nonatomic) MGLStyleValue *position; /** - Values describing animated transitions to `position` property. - */ -@property (nonatomic) MGLTransition positionTransiton; + The transition affecting any changes to this layer’s `position` property. + This property corresponds to the `position-transition` property in the style JSON file format. +*/ +@property (nonatomic) MGLTransition positionTransition; #if TARGET_OS_IPHONE /** Color tint for lighting extruded geometries. + The default value of this property is an `MGLStyleValue` object containing + `UIColor.whiteColor`. + + You can set this property to an instance of: + + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + This property corresponds to the color light property in the Mapbox Style Specification. */ @property (nonatomic) MGLStyleValue *color; #else - /** Color tint for lighting extruded geometries. + + The default value of this property is an `MGLStyleValue` object containing + `NSColor.whiteColor`. + + You can set this property to an instance of: + + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + + This property corresponds to the color + light property in the Mapbox Style Specification. */ @property (nonatomic) MGLStyleValue *color; #endif /** - Values describing animated transitions to `color` property. - */ -@property (nonatomic) MGLTransition colorTransiton; + The transition affecting any changes to this layer’s `color` property. + This property corresponds to the `color-transition` property in the style JSON file format. +*/ +@property (nonatomic) MGLTransition colorTransition; /** - Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast. + Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as + more extreme contrast. + + The default value of this property is an `MGLStyleValue` object containing an + `NSNumber` object containing the float `0.5`. + + You can set this property to an instance of: + * `MGLConstantStyleValue` + * `MGLCameraStyleFunction` with an interpolation mode of: + * `MGLInterpolationModeExponential` + * `MGLInterpolationModeInterval` + This property corresponds to the intensity light property in the Mapbox Style Specification. */ -@property(nonatomic) MGLStyleValue *intensity; +@property (nonatomic) MGLStyleValue *intensity; /** - Values describing animated transitions to `intensity` property. - */ + The transition affecting any changes to this layer’s `intensity` property. + + This property corresponds to the `intensity-transition` property in the style JSON file format. +*/ @property (nonatomic) MGLTransition intensityTransition; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLight.h.ejs b/platform/darwin/src/MGLLight.h.ejs new file mode 100644 index 0000000000..26ecefc3af --- /dev/null +++ b/platform/darwin/src/MGLLight.h.ejs @@ -0,0 +1,100 @@ +<% + const properties = locals.properties; + const type = locals.type; + const doc = locals.doc; +-%> +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. + +#import + +#import "MGLFoundation.h" +#import "MGLStyleValue.h" + +NS_ASSUME_NONNULL_BEGIN + +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> +/** +<%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %> + */ +typedef NS_ENUM(NSUInteger, MGLLight<%- camelize(property.name) %>) { +<% for (const value in property.values) { -%> + /** +<%- propertyDoc(property.name, property.values[value], type, 'enum').wrap(80, 4+1) %> + */ + MGLLightAnchor<%- camelize(value) %>, +<% } -%> +}; +<% } -%> +<% } -%> + +/** + A structure containing information about the position of the light source + relative to lit geometries. + */ +typedef struct MGLSphericalPosition { + /** Distance from the center of the base of an object to its light. */ + CGFloat radial; + /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds + to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, + and degrees proceed clockwise). */ + CLLocationDirection azimuthal; + /** Indicates the height of the light (from 0°, directly above, to 180°, directly below). */ + CLLocationDirection polar; +} MGLSphericalPosition; + +/** + Creates a new `MGLSphericalPosition` from the given radial, azimuthal, polar. + + @param radial The radial coordinate. + @param azimuthal The azimuthal angle. + @param polar The polar angle. + + @return Returns a `MGLSphericalPosition` struct containing the position attributes. + */ +NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocationDirection azimuthal, CLLocationDirection polar) { + MGLSphericalPosition position; + position.radial = radial; + position.azimuthal = azimuthal; + position.polar = polar; + + return position; +} + +/** + <%- doc %> + */ +MGL_EXPORT +@interface MGLLight : NSObject +<% if (properties.length) { -%> + +<% for (const property of properties) { -%> +/** +<%- propertyDoc(property.name, property, type, 'light').wrap(80, 1) %> + + This property corresponds to the <%- originalPropertyName(property) %> + light property in the Mapbox Style Specification. + */ +@property (nonatomic<% if (property.getter) { %>, getter=<%- objCGetter(property) -%><% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; + +<% if (property.transition) { -%> +/** + The transition affecting any changes to this layer’s `<%- camelizeWithLeadingLowercase(property.name) %>` property. + + This property corresponds to the `<%- originalPropertyName(property) %>-transition` property in the style JSON file format. +*/ +@property (nonatomic) MGLTransition <%- camelizeWithLeadingLowercase(property.name) %>Transition; + +<% } -%> +<% if (property.original) { -%> +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> __attribute__((unavailable("Use <%- camelizeWithLeadingLowercase(property.name) %> instead."))); + +<% } -%> +<% } -%> +<% } -%> + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLight.mm b/platform/darwin/src/MGLLight.mm index 262fad3b07..c83ef127a6 100644 --- a/platform/darwin/src/MGLLight.mm +++ b/platform/darwin/src/MGLLight.mm @@ -1,3 +1,7 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. +// test + #import "MGLLight.h" #import "MGLTypes.h" @@ -9,7 +13,7 @@ #import namespace mbgl { - + MBGL_DEFINE_ENUM(MGLLightAnchor, { { MGLLightAnchorMap, "map" }, { MGLLightAnchorViewport, "viewport" }, @@ -47,11 +51,9 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition } else { anchorStyleValue = MGLStyleValueTransformer().toEnumStyleValue(anchor); } - + _anchor = anchorStyleValue; - - _anchorTransition = MGLTransitionFromOptions(mbglLight->getAnchorTransition()); - + auto positionValue = mbglLight->getPosition(); if (positionValue.isUndefined()) { _position = MGLStyleValueTransformer().toStyleValue(mbglLight->getDefaultPosition()); @@ -59,8 +61,8 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition _position = MGLStyleValueTransformer().toStyleValue(positionValue); } - _positionTransiton = MGLTransitionFromOptions(mbglLight->getPositionTransition()); - + _positionTransition = MGLTransitionFromOptions(mbglLight->getPositionTransition()); + auto colorValue = mbglLight->getColor(); if (colorValue.isUndefined()) { _color = MGLStyleValueTransformer().toStyleValue(mbglLight->getDefaultColor()); @@ -68,8 +70,8 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition _color = MGLStyleValueTransformer().toStyleValue(colorValue); } - _colorTransiton = MGLTransitionFromOptions(mbglLight->getColorTransition()); - + _colorTransition = MGLTransitionFromOptions(mbglLight->getColorTransition()); + auto intensityValue = mbglLight->getIntensity(); if (intensityValue.isUndefined()) { _intensity = MGLStyleValueTransformer().toStyleValue(mbglLight->getDefaultIntensity()); @@ -78,6 +80,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition } _intensityTransition = MGLTransitionFromOptions(mbglLight->getIntensityTransition()); + } return self; @@ -86,26 +89,24 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition - (mbgl::style::Light)mbglLight { mbgl::style::Light mbglLight; - auto anchor = MGLStyleValueTransformer().toEnumPropertyValue(self.anchor); mbglLight.setAnchor(anchor); - - mbglLight.setAnchorTransition(MGLOptionsFromTransition(self.anchorTransition)); - + auto position = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.position); mbglLight.setPosition(position); - - mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransiton)); - + + mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransition)); + auto color = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.color); mbglLight.setColor(color); - - mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransiton)); - + + mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransition)); + auto intensity = MGLStyleValueTransformer().toInterpolatablePropertyValue(self.intensity); mbglLight.setIntensity(intensity); - + mbglLight.setIntensityTransition(MGLOptionsFromTransition(self.intensityTransition)); + return mbglLight; } diff --git a/platform/darwin/src/MGLLight.mm.ejs b/platform/darwin/src/MGLLight.mm.ejs new file mode 100644 index 0000000000..0d0da124c8 --- /dev/null +++ b/platform/darwin/src/MGLLight.mm.ejs @@ -0,0 +1,114 @@ +<% + const properties = locals.properties; +-%> +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. +// test + +#import "MGLLight.h" + +#import "MGLTypes.h" +#import "NSDate+MGLAdditions.h" +#import "MGLStyleValue_Private.h" +#import "NSValue+MGLAdditions.h" + +#import +#import + +namespace mbgl { + + MBGL_DEFINE_ENUM(MGLLightAnchor, { +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> +<% for (const value in property.values) { -%> + { MGLLightAnchor<%- camelize(value) %>, "<%- value %>" }, +<% } -%> +<% } -%> +<% } -%> + }); + +} + +NS_INLINE MGLTransition MGLTransitionFromOptions(const mbgl::style::TransitionOptions& options) { + MGLTransition transition; + transition.duration = MGLTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); + transition.delay = MGLTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); + + return transition; +} + +NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition transition) { + mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; + return options; +} + +@interface MGLLight() + +@end + +@implementation MGLLight + +- (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight +{ + if (self = [super init]) { +<% if (properties.length) { -%> +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> + auto <%- camelizeWithLeadingLowercase(property.name) -%> = mbglLight->get<%- camelize(property.name) -%>(); + MGLStyleValue *<%- camelizeWithLeadingLowercase(property.name) -%>StyleValue; + if (<%- camelizeWithLeadingLowercase(property.name) -%>.isUndefined()) { + mbgl::style::PropertyValueType> default<%- camelize(property.name) -%> = mbglLight->getDefault<%- camelize(property.name) -%>(); + <%- camelizeWithLeadingLowercase(property.name) -%>StyleValue = MGLStyleValueTransformerType, MGLLight<%- camelize(property.name) -%>>().toEnumStyleValue(default<%- camelize(property.name) -%>); + } else { + <%- camelizeWithLeadingLowercase(property.name) -%>StyleValue = MGLStyleValueTransformerType, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toEnumStyleValue(<%- camelizeWithLeadingLowercase(property.name) -%>); + } + + _<%- camelizeWithLeadingLowercase(property.name) -%> = <%- camelizeWithLeadingLowercase(property.name) -%>StyleValue; + +<% if (property.transition) { -%> + _<%- camelizeWithLeadingLowercase(property.name) -%>Transition = MGLTransitionFromOptions(mbglLight->get<%- camelize(property.name) -%>Transition()); + +<% } -%> +<% } else {-%> + auto <%- camelizeWithLeadingLowercase(property.name) -%>Value = mbglLight->get<%- camelize(property.name) -%>(); + if (<%- camelizeWithLeadingLowercase(property.name) -%>Value.isUndefined()) { + _<%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(mbglLight->getDefault<%- camelize(property.name) -%>()); + } else { + _<%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(<%- camelizeWithLeadingLowercase(property.name) -%>Value); + } +<% if (property.transition) { -%> + _<%- camelizeWithLeadingLowercase(property.name) -%>Transition = MGLTransitionFromOptions(mbglLight->get<%- camelize(property.name) -%>Transition()); +<% } -%> +<% } -%> +<% } -%> +<% } -%> + } + + return self; +} + +- (mbgl::style::Light)mbglLight +{ + mbgl::style::Light mbglLight; +<% if (properties.length) { -%> +<% for (const property of properties) { -%> +<% if (property.type == "enum") { -%> + auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformerType, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toEnumPropertyValue(self.<%- camelizeWithLeadingLowercase(property.name) -%>); + mbglLight.set<%- camelize(property.name) -%>(<%- camelizeWithLeadingLowercase(property.name) -%>); + +<% } else {-%> + auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toInterpolatablePropertyValue(self.<%- camelizeWithLeadingLowercase(property.name) -%>); + mbglLight.set<%- camelize(property.name) -%>(<%- camelizeWithLeadingLowercase(property.name) -%>); + +<% } -%> +<% if (property.transition) { -%> + mbglLight.set<%- camelize(property.name) -%>Transition(MGLOptionsFromTransition(self.<%- camelizeWithLeadingLowercase(property.name) -%>Transition)); + +<% } -%> +<% } -%> +<% } -%> + + return mbglLight; +} + +@end -- cgit v1.2.1 From 2a5dc2d55b759541ed7e807a7b889a283b0c8372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Wed, 14 Jun 2017 17:35:08 -0700 Subject: [ios, macos] Rewrote MGLStyle class documentation The documentation comment now provides a high-level overview of the runtime styling API and its components, as well as the main workflow for using a style. --- platform/darwin/src/MGLStyle.h | 53 +++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 08c6c047f1..8ffd7db2b2 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -32,14 +32,51 @@ NS_ASSUME_NONNULL_BEGIN static MGL_EXPORT const NSInteger MGLStyleDefaultVersion = 10; /** - The proxy object for the current map style. - - MGLStyle provides a set of convenience methods for changing Mapbox - default styles using `-[MGLMapView styleURL]`. - Learn more about Mapbox default styles. - - It is also possible to directly manipulate the current map style - via `-[MGLMapView style]` by updating the style's data sources or layers. + An `MGLStyle` object represents the active map style of an `MGLMapView`. A + style defines both the map’s content and every aspect of its appearance. Styles + can be designed in + Mapbox Studio and hosted on + mapbox.com. `MGLStyle` provides methods for inspecting and manipulating a style + dynamically, with classes and properties that parallel the style JSON format + defined by the + Mapbox Style Specification. + + You set a map view’s active style using the `MGLMapView.styleURL` property. + `MGLStyle` provides a set of convenience methods that return the URLs of + popular Mapbox-designed styles. + Once the `-[MGLMapViewDelegate mapView:didFinishLoadingStyle:]` or + `-[MGLMapViewDelegate mapViewDidFinishLoadingMap:]` method is called, signaling + that the style has finished loading, you can use the `MGLMapView.style` + property to obtain the map view’s `MGLStyle`. + + A style primarily consists of the following components: + + * _Content sources_ supply content to be shown on the map. Use methods such as + `-sourceWithIdentifier:` and `-addSource:` to configure the style’s content + sources, which are represented by `MGLSource` objects. + * _Style layers_ manage the layout and appearance of content at specific + z-indices in the style. Most kinds of style layers display content provided + by a content source. Use methods such as `-layerWithIdentifier:` and + `-addLayer:` to configure the style’s layers, which are represented by + `MGLStyleLayer` objects. + * _Style images_ are used as icons and patterns in style layers. Use the + `-setImage:forName:` method to register an image as a style image. + (Annotations are represented by annotation images rather than style images. + To configure an annotation’s appearance, use the + `-[MGLMapViewDelegate mapView:imageForAnnotation:]` method.) + * The style’s _light_ is the light source affecting any 3D extruded fills. + Use the `light` property to configure the style’s light, which is represented + by an `MGLLight` object. + + The `MGLStyle`, `MGLSource`, `MGLStyleLayer`, and `MGLLight` classes are + collectively known as the _runtime styling API_. The active style influences a + related API, visible feature querying, which is available through methods such + as `-[MGLMapView visibleFeaturesInRect:]`. + + Some terminology differs between the Mapbox Style Specification and the various + classes associated with `MGLStyle`. Consult the + “[Information for Style Authors](../for-style-authors.html)” guide for an + overview of these differences. @note Wait until the map style has finished loading before modifying a map's style via any of the `MGLStyle` instance methods below. You can use the -- cgit v1.2.1 From b7ec96d352c78172b6df4afedd6fc0e7db142a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 16 Jun 2017 10:28:02 -0700 Subject: [ios, macos] Corrected MGLSource subclassing documentation --- platform/darwin/src/MGLSource.h | 4 ++-- platform/darwin/src/MGLVectorStyleLayer.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLSource.h b/platform/darwin/src/MGLSource.h index 151363104e..a504a01791 100644 --- a/platform/darwin/src/MGLSource.h +++ b/platform/darwin/src/MGLSource.h @@ -17,8 +17,8 @@ NS_ASSUME_NONNULL_BEGIN `-[MGLStyle addSource:]` and `-[MGLStyle sourceWithIdentifier:]`. Create instances of `MGLShapeSource` and the concrete subclasses of - `MGLTileSource`, `MGLVectorSource` and `MGLRasterSource` in order to use - `MGLMultiPoint`'s properties and methods. Do not create instances of `MGLSource` + `MGLTileSource` (`MGLVectorSource` and `MGLRasterSource`) in order to use + `MGLSource`'s properties and methods. Do not create instances of `MGLSource` directly, and do not create your own subclasses of this class. */ MGL_EXPORT diff --git a/platform/darwin/src/MGLVectorStyleLayer.h b/platform/darwin/src/MGLVectorStyleLayer.h index e54a580aed..6603570e25 100644 --- a/platform/darwin/src/MGLVectorStyleLayer.h +++ b/platform/darwin/src/MGLVectorStyleLayer.h @@ -9,10 +9,11 @@ NS_ASSUME_NONNULL_BEGIN `MGLVectorStyleLayer` is an abstract superclass for style layers whose content is defined by an `MGLShapeSource` or `MGLVectorSource` object. - Create instances of `MGLCircleStyleLayer`, `MGLFillStyleLayer`, `MGLLineStyleLayer`, - and `MGLSymbolStyleLayer` in order to use `MGLVectorStyleLayer`'s properties and - methods. Do not create instances of `MGLVectorStyleLayer` directly, and do not - create your own subclasses of this class. + Create instances of `MGLCircleStyleLayer`, `MGLFillStyleLayer`, + `MGLFillExtrusionStyleLayer`, `MGLLineStyleLayer`, and `MGLSymbolStyleLayer` in + order to use `MGLVectorStyleLayer`'s properties and methods. Do not create + instances of `MGLVectorStyleLayer` directly, and do not create your own + subclasses of this class. */ MGL_EXPORT @interface MGLVectorStyleLayer : MGLForegroundStyleLayer -- cgit v1.2.1 From a1c5b32da66a32e52e24163f826dabbc1e4d38bf Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Thu, 22 Jun 2017 14:36:21 -0400 Subject: Boxing ObjC structs (#9343) * [ios, macos] Make structs boxable * [ios, macos] Update changelogs. --- platform/darwin/src/MGLGeometry.h | 4 ++-- platform/darwin/src/MGLLight.h | 2 +- platform/darwin/src/MGLOfflinePack.h | 2 +- platform/darwin/src/MGLTypes.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLGeometry.h b/platform/darwin/src/MGLGeometry.h index 9fcb9dd37c..d37741cde5 100644 --- a/platform/darwin/src/MGLGeometry.h +++ b/platform/darwin/src/MGLGeometry.h @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** Defines the area spanned by an `MGLCoordinateBounds`. */ -typedef struct MGLCoordinateSpan { +typedef struct __attribute__((objc_boxable)) MGLCoordinateSpan { /** Latitudes spanned by an `MGLCoordinateBounds`. */ CLLocationDegrees latitudeDelta; /** Longitudes spanned by an `MGLCoordinateBounds`. */ @@ -38,7 +38,7 @@ NS_INLINE BOOL MGLCoordinateSpanEqualToCoordinateSpan(MGLCoordinateSpan span1, M extern MGL_EXPORT const MGLCoordinateSpan MGLCoordinateSpanZero; /** A rectangular area as measured on a two-dimensional map projection. */ -typedef struct MGLCoordinateBounds { +typedef struct __attribute__((objc_boxable)) MGLCoordinateBounds { /** Coordinate at the southwest corner. */ CLLocationCoordinate2D sw; /** Coordinate at the northeast corner. */ diff --git a/platform/darwin/src/MGLLight.h b/platform/darwin/src/MGLLight.h index 55b789f043..50db3f45fd 100644 --- a/platform/darwin/src/MGLLight.h +++ b/platform/darwin/src/MGLLight.h @@ -27,7 +27,7 @@ typedef NS_ENUM(NSUInteger, MGLLightAnchor) { A structure containing information about the position of the light source relative to lit geometries. */ -typedef struct MGLSphericalPosition { +typedef struct __attribute__((objc_boxable)) MGLSphericalPosition { /** Distance from the center of the base of an object to its light. */ CGFloat radial; /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds diff --git a/platform/darwin/src/MGLOfflinePack.h b/platform/darwin/src/MGLOfflinePack.h index 0b2db35b1a..dfc47bf1c8 100644 --- a/platform/darwin/src/MGLOfflinePack.h +++ b/platform/darwin/src/MGLOfflinePack.h @@ -54,7 +54,7 @@ typedef NS_ENUM (NSInteger, MGLOfflinePackState) { A structure containing information about an offline pack’s current download progress. */ -typedef struct MGLOfflinePackProgress { +typedef struct __attribute__((objc_boxable)) MGLOfflinePackProgress { /** The number of resources, including tiles, that have been completely downloaded and are ready to use offline. diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index 16f510b5a6..b3227e1cdf 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -78,7 +78,7 @@ typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) { /** A structure containing information about a transition. */ -typedef struct MGLTransition { +typedef struct __attribute__((objc_boxable)) MGLTransition { /** The amount of time the animation should take, not including the delay. */ -- cgit v1.2.1 From 79d849dc44e977ca8711adb7a397e5e560cbc80a Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 5 Jul 2017 21:15:54 +0200 Subject: [darwin] - re-add swift documentation --- platform/darwin/src/MGLCircleStyleLayer.h | 10 ++++++++++ platform/darwin/src/MGLFillExtrusionStyleLayer.h | 6 ++++++ platform/darwin/src/MGLFillStyleLayer.h | 5 +++++ platform/darwin/src/MGLLineStyleLayer.h | 10 ++++++++++ platform/darwin/src/MGLRasterStyleLayer.h | 3 +++ platform/darwin/src/MGLSymbolStyleLayer.h | 10 ++++++++++ 6 files changed, 44 insertions(+) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index 823824b50f..789ff7a258 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -64,6 +64,16 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) { ### Example ```swift + let layer = MGLCircleStyleLayer(identifier: "circles", source: population) + layer.sourceLayerIdentifier = "population" + layer.circleColor = MGLStyleValue(rawValue: .green) + layer.circleRadius = MGLStyleValue(interpolationMode: .exponential, + cameraStops: [12: MGLStyleValue(rawValue: 2), + 22: MGLStyleValue(rawValue: 180)], + options: [.interpolationBase: 1.75]) + layer.circleOpacity = MGLStyleValue(rawValue: 0.7) + layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married") + mapView.style?.addLayer(layer) ``` */ MGL_EXPORT diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.h b/platform/darwin/src/MGLFillExtrusionStyleLayer.h index 443391756d..c4fb9aa77e 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.h +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.h @@ -42,6 +42,12 @@ typedef NS_ENUM(NSUInteger, MGLFillExtrusionTranslationAnchor) { ### Example ```swift + let layer = MGLFillExtrusionStyleLayer(identifier: "buildings", source: buildings) + layer.sourceLayerIdentifier = "building" + layer.fillExtrusionHeight = MGLStyleValue(interpolationMode: .identity, sourceStops: nil, attributeName: "height", options: nil) + layer.fillExtrusionBase = MGLStyleValue(interpolationMode: .identity, sourceStops: nil, attributeName: "min_height", options: nil) + layer.predicate = NSPredicate(format: "extrude == 'true'") + mapView.style?.addLayer(layer) ``` */ MGL_EXPORT diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index 8776f17bcb..6e3297bdec 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -42,6 +42,11 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) { ### Example ```swift + let layer = MGLFillStyleLayer(identifier: "parks", source: parks) + layer.sourceLayerIdentifier = "parks" + layer.fillColor = MGLStyleValue(rawValue: .green) + layer.predicate = NSPredicate(format: "type == %@", "national-park") + mapView.style?.addLayer(layer) ``` */ MGL_EXPORT diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index 7c5b66a2c2..4a96b11abf 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -92,6 +92,16 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslationAnchor) { ### Example ```swift + let layer = MGLLineStyleLayer(identifier: "trails-path", source: trails) + layer.sourceLayerIdentifier = "trails" + layer.lineWidth = MGLStyleValue(interpolationMode: .exponential, + cameraStops: [14: MGLStyleValue(rawValue: 2), + 18: MGLStyleValue(rawValue: 20)], + options: [.interpolationBase: 1.5]) + layer.lineColor = MGLStyleValue(rawValue: .brown) + layer.lineCap = MGLStyleValue(rawValue: NSValue(mglLineCap: .round)) + layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking") + mapView.style?.addLayer(layer) ``` */ MGL_EXPORT diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index 09fafd114d..53a6a98b8a 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.h +++ b/platform/darwin/src/MGLRasterStyleLayer.h @@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN ### Example ```swift + let layer = MGLRasterStyleLayer(identifier: "clouds", source: source) + layer.rasterOpacity = MGLStyleValue(rawValue: 0.5) + mapView.style?.addLayer(layer) ``` */ MGL_EXPORT diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index 8512870e1b..5df995aa01 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -265,6 +265,16 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) { ### Example ```swift + let layer = MGLSymbolStyleLayer(identifier: "coffeeshops", source: pois) + layer.sourceLayerIdentifier = "pois" + layer.iconImageName = MGLStyleValue(rawValue: "coffee") + layer.iconScale = MGLStyleValue(rawValue: 0.5) + layer.text = MGLStyleValue(rawValue: "{name}") + layer.textTranslation = MGLStyleValue(rawValue: NSValue(cgVector: CGVector(dx: 10, dy: 0))) + layer.textJustification = MGLStyleValue(rawValue: NSValue(mglTextJustification: .left)) + layer.textAnchor = MGLStyleValue(rawValue: NSValue(mglTextAnchor: .left)) + layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee") + mapView.style?.addLayer(layer) ``` */ MGL_EXPORT -- cgit v1.2.1