diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java | 106 |
1 files changed, 105 insertions, 1 deletions
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 50192d8f8d..8a8a351db3 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 @@ -1,8 +1,12 @@ package com.mapbox.mapboxsdk.maps; +import android.support.annotation.StringDef; import com.mapbox.mapboxsdk.style.layers.Layer; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.sources.Source; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.HashMap; public class Style { @@ -15,7 +19,7 @@ public class Style { this.nativeMapView = nativeMapView; } - public void loadStyle(@com.mapbox.mapboxsdk.constants.Style.StyleUrl String styleUrl) { + public void loadStyle(@StyleUrl String styleUrl) { for (Source source : sources.values()) { if (source != null) { source.setDetached(); @@ -67,5 +71,105 @@ public class Style { return layer; } + // + // Transition + // + + + /** + * <p> + * Set the transition duration for style changes. + * </p> + * The default value for delay and duration is zero, so any changes take effect without animation. + * + * @param transitionOptions the transition options + */ + public void setTransition(TransitionOptions transitionOptions) { + nativeMapView.setTransitionDuration(transitionOptions.getDuration()); + nativeMapView.setTransitionDelay(transitionOptions.getDelay()); + } + + /** + * <p> + * Get the transition for style changes. + * </p> + * The default value for delay and transition is zero, so any changes take effect without animation. + * + * @return TransitionOptions the transition options + */ + public TransitionOptions getTransition() { + return new TransitionOptions(nativeMapView.getTransitionDuration(), nativeMapView.getTransitionDelay()); + } + + // + // Style constants + // + + /** + * Indicates the parameter accepts one of the values from Style. Using one of these + * constants means your map style will always use the latest version and may change as we + * improve the style + */ + @StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT}) + @Retention(RetentionPolicy.SOURCE) + public @interface StyleUrl { + } + // IMPORTANT: If you change any of these you also need to edit them in strings.xml + + /** + * Mapbox Streets: A complete basemap, perfect for incorporating your own data. Using this + * constant means your map style will always use the latest version and may change as we + * improve the style. + */ + public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v10"; + + /** + * Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means + * your map style will always use the latest version and may change as we improve the style. + */ + public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v10"; + + /** + * Light: Subtle light backdrop for data visualizations. Using this constant means your map + * style will always use the latest version and may change as we improve the style. + */ + public static final String LIGHT = "mapbox://styles/mapbox/light-v9"; + + /** + * Dark: Subtle dark backdrop for data visualizations. Using this constant means your map style + * will always use the latest version and may change as we improve the style. + */ + public static final String DARK = "mapbox://styles/mapbox/dark-v9"; + + /** + * Satellite: A beautiful global satellite and aerial imagery layer. Using this constant means + * your map style will always use the latest version and may change as we improve the style. + */ + public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v9"; + + /** + * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. Using this + * constant means your map style will always use the latest version and may change as we + * improve the style. + */ + public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v10"; + + /** + * Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently + * available in + * <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select + * countries</a>. Using this constant means your map style will always use the latest version and + * may change as we improve the style. + */ + public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2"; + + /** + * Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize + * legibility in low-light situations. Traffic data is currently available in + * <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select + * countries</a>. Using this constant means your map style will always use the latest version and + * may change as we improve the style. + */ + public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2"; } |