Skip to content

Commit 477082d

Browse files
feat(lineMetrics): added source property lineMetrics
In order to use line gradients, the option `lineMetrics` is needed. On iOS side, this is achieved by setting MGLShapeSourceOptionLineDistanceMetrics(https://mapbox.github.io/mapbox-gl-native/macos/0.12.0/Other%20Constants.html#/c:@MGLShapeSourceOptionLineDistanceMetrics) and on Android it can be set with `withLineMetrics` on the `GeoJsonOptions`. The option `lineMetrics` was added to the `GeoJSONSource` API object and is used in the `addSource(...)` methods on iOS and Android as described above.
1 parent e6c89b9 commit 477082d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/ui-mapbox/common.ts

+1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ export interface GeoJSONSource extends Source {
342342
data?: any;
343343
minzoom?: number;
344344
maxzoom?: number;
345+
lineMetrics?: boolean;
345346
cluster?: {
346347
radius;
347348
maxZoom;

src/ui-mapbox/index.android.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,11 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
25052505
if (options.maxzoom) {
25062506
geojsonOptions.withMaxZoom(options.maxzoom);
25072507
}
2508+
2509+
if (options.lineMetrics !== undefined) {
2510+
geojsonOptions.withLineMetrics(options.lineMetrics);
2511+
}
2512+
25082513
if (options.cluster) {
25092514
geojsonOptions
25102515
.withCluster(true)

src/ui-mapbox/index.ios.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,9 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
27732773
if (options.maxzoom !== undefined) {
27742774
sourceOptions[MGLShapeSourceOptionMaximumZoomLevel] = options.maxzoom;
27752775
}
2776-
2776+
if (options.lineMetrics !== undefined) {
2777+
sourceOptions[MGLShapeSourceOptionLineDistanceMetrics] = options.lineMetrics;
2778+
}
27772779
if (options.cluster) {
27782780
sourceOptions[MGLShapeSourceOptionClustered] = true;
27792781
sourceOptions[MGLShapeSourceOptionClusterRadius] = options.cluster.radius || 40;

0 commit comments

Comments
 (0)