[android] Fix style urls

Fixes #5193
This commit is contained in:
Cameron
2016-06-03 12:05:06 -04:00
parent c9c6ea7d6f
commit 0bfe951b55
16 changed files with 61 additions and 188 deletions

View File

@@ -1,7 +1,9 @@
package com.mapbox.mapboxsdk.constants;
import android.support.annotation.StringDef;
import com.mapbox.mapboxsdk.maps.MapView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -15,156 +17,32 @@ 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 general-purpose style tailored to 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-streets-v%d";
/**
* Satellite Streets: Global satellite and aerial imagery with unobtrusive labels (Version 8).
* Indicates the parameter accepts one of the values from {@link Style}. Using one of these
* constants means your map style will always use the latest version and may change as we
* improve the style
*/
private static final String SATELLITE_STREETS_V8 = "mapbox://styles/mapbox/satellite-hybrid-v8";
/**
* Get versioned url of Mapbox streets style.
* <ul>
* <li>Current default version is 9.</li>
* </ul>
* <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(MapboxConstants.MAPBOX_LOCALE, MAPBOX_STREETS_BASE, version);
}
/**
* Get versioned url of Outdoors streets style.
* <ul>
* <li>Current version is 9.</li>
* </ul>
* <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(MapboxConstants.MAPBOX_LOCALE, OUTDOORS_BASE, version);
}
/**
* Get versioned url of Light style.
* <ul>
* <li>Current default version is 9.</li>
* </ul>
* <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(MapboxConstants.MAPBOX_LOCALE, LIGHT_BASE, version);
}
/**
* Get versioned url of Dark style.
* <ul>
* <li>Current default version is 9.</li>
* </ul>
* <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(MapboxConstants.MAPBOX_LOCALE, DARK_BASE, version);
}
/**
* Get versioned url of Satellite style.
* <ul>
* <li>Current version is 9.</li>
* </ul>
* <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(MapboxConstants.MAPBOX_LOCALE, SATELLITE_BASE, version);
}
/**
* Get versioned url of Satellite streets style.
* <ul>
* <li>Current version is 9.</li>
* </ul>
* <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) {
if (version == 8) {
return SATELLITE_STREETS_V8;
}
return String.format(MapboxConstants.MAPBOX_LOCALE, 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})
@StringDef({MAPBOX_STREETS, OUTDOORS, EMERALD, LIGHT, DARK, SATELLITE, SATELLITE_STREETS})
@Retention(RetentionPolicy.SOURCE)
@Deprecated
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.
*
* @deprecated use {@link #getMapboxStreetsUrl(int)} instead.
* 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.
*/
@Deprecated
public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v9";
/**
* 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-v9";
/**
* Emerald: A versatile style, with emphasis on road networks and public transit.
*
@@ -174,34 +52,27 @@ public class Style {
public static final String EMERALD = "mapbox://styles/mapbox/emerald-v8";
/**
* Light: Subtle light backdrop for data visualizations.
*
* @deprecated use {@link #getLightStyleUrl(int)} instead.
* 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.
*/
@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.
* 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.
*/
@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.
* 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.
*/
@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.
* 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.
*/
@Deprecated
public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v9";
}

View File

@@ -783,7 +783,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#getMapboxStreetsUrl(int)} style.</li>
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
* </ul>
* <p>
* This method is asynchronous and will return immediately before the style finishes loading.
@@ -2708,7 +2708,7 @@ public class MapView extends FrameLayout {
private boolean mDefaultStyle;
StyleInitializer(@NonNull Context context) {
mStyle = Style.getMapboxStreetsUrl(context.getResources().getInteger(R.integer.style_version));
mStyle = Style.MAPBOX_STREETS;
mDefaultStyle = true;
}

View File

@@ -549,7 +549,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#getMapboxStreetsUrl(int)} style.</li>
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
* </ul>
* <p>
* This method is asynchronous and will return immediately before the style finishes loading.