diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-11-08 14:20:14 +0100 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-12-10 16:59:50 +0100 |
commit | 94451b41ef5ede1f3f1534f0f6c94356663ae23b (patch) | |
tree | f99c050427df48f59eaef1be153a7bd5440113ee | |
parent | 470bc66f0fdadb2eb862953998a1ee433b49bc14 (diff) | |
download | qtlocation-mapboxgl-94451b41ef5ede1f3f1534f0f6c94356663ae23b.tar.gz |
[android] - expose style builder
2 files changed, 63 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 6d68302c61..2211d4bd1d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -95,7 +95,7 @@ public final class MapboxMap { setPrefetchesTiles(options); } - public Style getStyle(){ + public Style getStyle() { return style; } @@ -679,6 +679,11 @@ public final class MapboxMap { // Styling // + public void setStyle(Style.Builder builder) { + + } + + /** * <p> * Loads a new map style asynchronous from the specified URL. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java index 9e8748ce4b..9cc14d67db 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java @@ -12,6 +12,7 @@ import com.mapbox.mapboxsdk.style.sources.Source; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -326,6 +327,62 @@ public class Style { } // + // Builder + // + + public static class Builder { + + private String styleUrl; + private String styleJson; + private List<Source> sources = new ArrayList<>(); + // TODO allow adding below and at index + private List<Layer> layers = new ArrayList<>(); + private TransitionOptions transitionOptions; + + public Builder withStyleUrl(@StyleUrl String styleUrl) { + this.styleUrl = styleUrl; + return this; + } + + public Builder withStyleJson(String styleJson) { + this.styleJson = styleJson; + return this; + } + + public Builder withSource(Source source) { + sources.add(source); + return this; + } + + public Builder withLayer(Layer layer) { + layers.add(layer); + return this; + } + + public Builder withTransition(TransitionOptions transition) { + this.transitionOptions = transition; + return this; + } + + Style build(NativeMapView nativeMapView) { + Style style = new Style(nativeMapView); + for (Source source : sources) { + style.addSource(source); + } + + for (Layer layer : layers) { + style.addLayer(layer); + } + + if (transitionOptions != null) { + style.setTransition(transitionOptions); + } + return style; + } + + } + + // // Style URL constants // |