diff options
author | Tobrun <tobrun@mapbox.com> | 2016-04-23 08:19:00 +0200 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-05-06 11:06:50 -0700 |
commit | da422ff44d6eda0376372d2e1c3cb9a1d01f89da (patch) | |
tree | c6b77c35b62797a4421195cea02c3f2400138cfc /platform/android/MapboxGLAndroidSDK/src/main/java/com | |
parent | 2a4eeadb295775236fe1a89b50f9179b790b127a (diff) | |
download | qtlocation-mapboxgl-da422ff44d6eda0376372d2e1c3cb9a1d01f89da.tar.gz |
[android] #4702 - upgrade default styles, deprecate Style string definition in favour versioned styling methods.
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com')
3 files changed, 171 insertions, 9 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java index 31c146b43e..61c7bfd9ce 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java @@ -1,11 +1,14 @@ package com.mapbox.mapboxsdk.constants; +import android.support.annotation.IntRange; import android.support.annotation.StringDef; import com.mapbox.mapboxsdk.maps.MapView; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Locale; + /** * <p> * Style provides URLs to several professional styles designed by Mapbox. @@ -17,10 +20,146 @@ import java.lang.annotation.RetentionPolicy; public class Style { /** + * Mapbox Streets: A complete basemap, perfect for incorporating your own data. + */ + private static final String MAPBOX_STREETS_BASE = "mapbox://styles/mapbox/streets-v%d"; + /** + * Outdoors: A rugged style that emphasizes physical terrain and outdoor activities. + */ + private static final String OUTDOORS_BASE = "mapbox://styles/mapbox/outdoors-v%d"; + /** + * Light: Subtle light backdrop for data visualizations. + */ + private static final String LIGHT_BASE = "mapbox://styles/mapbox/light-v%d"; + /** + * Dark: Subtle dark backdrop for data visualizations. + */ + private static final String DARK_BASE = "mapbox://styles/mapbox/dark-v%d"; + /** + * Satellite: A beautiful global satellite and aerial imagery layer. + */ + private static final String SATELLITE_BASE = "mapbox://styles/mapbox/satellite-v%d"; + /** + * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. + */ + private static final String SATELLITE_STREETS_BASE = "mapbox://styles/mapbox/satellite-hybrid-v%d"; + + /** + * Get versioned url of Mapbox streets style. + * <p> + * <ul> + * <li>Current default version is 9.</li> + * </ul + * </p> + * <p> + * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles + * </p> + * + * @param version the version of the style. + * @return uri to load style from + */ + public static String getMapboxStreetsUrl(int version) { + return String.format(Locale.US, MAPBOX_STREETS_BASE, version); + } + + /** + * Get versioned url of Outdoors streets style. + * <p> + * <ul> + * <li>Current version is 9.</li> + * </ul> + * </p> + * <p> + * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles + * </p> + * + * @param version the version of the style. + * @return uri to load style from + */ + public static String getOutdoorsStyleUrl(int version) { + return String.format(Locale.US, OUTDOORS_BASE, version); + } + + /** + * Get versioned url of Light style. + * <p> + * <ul> + * <li>Current default version is 9.</li> + * </ul> + * </p> + * <p> + * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles + * </p> + * + * @param version the version of the style. + * @return uri to load style from + */ + public static String getLightStyleUrl(int version) { + return String.format(Locale.US, LIGHT_BASE, version); + } + + /** + * Get versioned url of Dark style. + * <p> + * <ul> + * <li>Current default version is 9.</li> + * </ul> + * </p> + * <p> + * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles + * </p> + * + * @param version the version of the style. + * @return uri to load style from + */ + public static String getDarkStyleUrl(int version) { + return String.format(Locale.US, DARK_BASE, version); + } + + /** + * Get versioned url of Satellite style. + * <p> + * <ul> + * <li>Current version is 9.</li> + * </ul> + * </p> + * <p> + * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles + * </p> + * + * @param version the version of the style. + * @return uri to load style from + */ + public static String getSatelliteStyleUrl(int version) { + return String.format(Locale.US, SATELLITE_BASE, version); + } + + /** + * Get versioned url of Satellite streets style. + * <p> + * <ul> + * <li>Current version is 9.</li> + * </ul> + * </p> + * <p> + * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles + * </p> + * + * @param version the version of the style. + * @return uri to load style from + */ + public static String getSatelliteStreetsStyleUrl(int version) { + return String.format(Locale.US, SATELLITE_STREETS_BASE, version); + } + + /** * Indicates the parameter accepts one of the values from {@link Style}. + * + * @deprecated use dedicated versioned methods in {@link Style} instead. */ @StringDef({MAPBOX_STREETS, EMERALD, LIGHT, DARK, SATELLITE, SATELLITE_STREETS}) @Retention(RetentionPolicy.SOURCE) + @Deprecated public @interface StyleUrl { } @@ -28,28 +167,49 @@ public class Style { /** * Mapbox Streets: A complete basemap, perfect for incorporating your own data. + * + * @deprecated use {@link #getMapboxStreetsUrl(int)} instead. */ - public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v8"; + @Deprecated + public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v9"; + /** * Emerald: A versatile style, with emphasis on road networks and public transit. + * + * @deprecated this style has been deprecated and will be removed in future versions. */ + @Deprecated public static final String EMERALD = "mapbox://styles/mapbox/emerald-v8"; + /** * Light: Subtle light backdrop for data visualizations. + * + * @deprecated use {@link #getLightStyleUrl(int)} instead. */ - public static final String LIGHT = "mapbox://styles/mapbox/light-v8"; + @Deprecated + public static final String LIGHT = "mapbox://styles/mapbox/light-v9"; + /** * Dark: Subtle dark backdrop for data visualizations. + * + * @deprecated use {@link #getDarkStyleUrl(int)} (int)} instead. */ - public static final String DARK = "mapbox://styles/mapbox/dark-v8"; + @Deprecated + public static final String DARK = "mapbox://styles/mapbox/dark-v9"; + /** * Satellite: A beautiful global satellite and aerial imagery layer. + * + * @deprecated use {@link #getSatelliteStyleUrl(int)} instead. */ - public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v8"; + @Deprecated + public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v9"; /** * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. + * + * @deprecated use {@link #getSatelliteStreetsStyleUrl(int)} (int)} instead. */ - public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-hybrid-v8"; - + @Deprecated + public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-hybrid-v9"; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 16bc79a894..8266618b4b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -779,7 +779,7 @@ public class MapView extends FrameLayout { * <li>{@code asset://...}: * reads the style from the APK {@code assets/} directory. * This is used to load a style bundled with your app.</li> - * <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li> + * <li>{@code null}: loads the default {@link Style#getMapboxStreetsUrl(int)} style.</li> * </ul> * <p> * This method is asynchronous and will return immediately before the style finishes loading. @@ -2679,7 +2679,7 @@ public class MapView extends FrameLayout { private boolean mDefaultStyle; public StyleInitializer() { - mStyle = Style.MAPBOX_STREETS; + mStyle = Style.getMapboxStreetsUrl(getResources().getInteger(R.integer.style_version)); mDefaultStyle = true; } 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 31a9a73d95..36dc43fe32 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 @@ -523,7 +523,7 @@ public class MapboxMap { * <li>{@code asset://...}: * reads the style from the APK {@code assets/} directory. * This is used to load a style bundled with your app.</li> - * <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li> + * <li>{@code null}: loads the default {@link Style#getMapboxStreetsUrl(int)} style.</li> * </ul> * <p> * This method is asynchronous and will return immediately before the style finishes loading. @@ -553,8 +553,10 @@ public class MapboxMap { * * @param style The bundled style. Accepts one of the values from {@link Style}. * @see Style + * @deprecated use {@link #setStyleUrl(String)} instead with versioned url methods from {@link Style} */ @UiThread + @Deprecated public void setStyle(@Style.StyleUrl String style) { setStyleUrl(style); } |