From e0e5dbb161a105a40b9f0d88c6625f05ab54e106 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Fri, 10 Aug 2018 14:45:57 +0300 Subject: [ios, macos] Introduce `MGLShapeSourceOptionLineDistanceMetrics` Exposes access to https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-geojson-lineMetrics --- platform/darwin/docs/guides/For Style Authors.md.ejs | 1 + platform/darwin/src/MGLShapeSource.h | 12 ++++++++++++ platform/darwin/src/MGLShapeSource.mm | 9 +++++++++ platform/darwin/test/MGLShapeSourceTests.mm | 4 +++- platform/ios/CHANGELOG.md | 1 + platform/ios/docs/guides/For Style Authors.md | 1 + platform/macos/CHANGELOG.md | 1 + platform/macos/docs/guides/For Style Authors.md | 1 + 8 files changed, 29 insertions(+), 1 deletion(-) diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs index 940c9b1042..dd07ae9e76 100644 --- a/platform/darwin/docs/guides/For Style Authors.md.ejs +++ b/platform/darwin/docs/guides/For Style Authors.md.ejs @@ -222,6 +222,7 @@ In style JSON | In the SDK `cluster` | `MGLShapeSourceOptionClustered` `clusterRadius` | `MGLShapeSourceOptionClusterRadius` `clusterMaxZoom` | `MGLShapeSourceOptionMaximumZoomLevelForClustering` +`lineMetrics` | `MGLShapeSourceOptionLineDistanceMetrics` To create a shape source from local GeoJSON data, first [convert the GeoJSON data into a shape](working-with-geojson-data.html#converting-geojson-data-into-shape-objects), diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index e5c62515e5..c80c329cbc 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -95,6 +95,18 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionBuff */ FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance; +/** + An `NSNumber` object containing a Boolean enabling or disabling calculating line distance metrics. + + Set this property to `YES` in order for the `MGLLineStyleLayer.lineGradient` property to have its intended effect. + The default value is `NO`. + + This option corresponds to the + lineMetrics + source property in the Mapbox Style Specification. + */ +FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionLineDistanceMetrics; + /** `MGLShapeSource` is a map content source that supplies vector shapes to be shown on the map. The shapes may be instances of `MGLShape` or `MGLFeature`, diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index 1425269012..6512d07a66 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -20,6 +20,7 @@ const MGLShapeSourceOption MGLShapeSourceOptionMaximumZoomLevel = @"MGLShapeSour const MGLShapeSourceOption MGLShapeSourceOptionMaximumZoomLevelForClustering = @"MGLShapeSourceOptionMaximumZoomLevelForClustering"; const MGLShapeSourceOption MGLShapeSourceOptionMinimumZoomLevel = @"MGLShapeSourceOptionMinimumZoomLevel"; const MGLShapeSourceOption MGLShapeSourceOptionSimplificationTolerance = @"MGLShapeSourceOptionSimplificationTolerance"; +const MGLShapeSourceOption MGLShapeSourceOptionLineDistanceMetrics = @"MGLShapeSourceOptionLineDistanceMetrics"; mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary *options) { auto geoJSONOptions = mbgl::style::GeoJSONOptions(); @@ -80,6 +81,14 @@ mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary