diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps')
5 files changed, 114 insertions, 24 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 fa34e5b1f7..ea06856e9e 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 @@ -704,7 +704,7 @@ public final class MapboxMap { moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); setMinZoomPreference(minZoom); setMaxZoomPreference(maxZoom); - setStyle(new Style.Builder().fromUrl(definition.getStyleURL()), callback); + setStyle(new Style.Builder().fromUri(definition.getStyleURL()), callback); } // @@ -793,7 +793,7 @@ public final class MapboxMap { * @see Style */ public void setStyle(@Style.StyleUrl String style, final Style.OnStyleLoaded callback) { - this.setStyle(new Style.Builder().fromUrl(style), callback); + this.setStyle(new Style.Builder().fromUri(style), callback); } /** @@ -831,8 +831,8 @@ public final class MapboxMap { } style = builder.build(nativeMapView); - if (!TextUtils.isEmpty(builder.getUrl())) { - nativeMapView.setStyleUrl(builder.getUrl()); + if (!TextUtils.isEmpty(builder.getUri())) { + nativeMapView.setStyleUri(builder.getUri()); } else if (!TextUtils.isEmpty(builder.getJson())) { nativeMapView.setStyleJson(builder.getJson()); } else { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 389cb0a0a9..cc2124c6c7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -11,9 +11,9 @@ import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.res.ResourcesCompat; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.Gravity; - import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MapboxConstants; @@ -70,7 +70,7 @@ public class MapboxMapOptions implements Parcelable { private boolean zMediaOverlay = false; private String localIdeographFontFamily = "sans-serif"; - private String apiBaseUrl; + private String apiBaseUri; private boolean textureMode; private boolean translucentTextureSurface; @@ -84,6 +84,7 @@ public class MapboxMapOptions implements Parcelable { /** * Creates a new MapboxMapOptions object. + * * @deprecated Use {@link #createFromAttributes(Context, AttributeSet)} instead. */ @Deprecated @@ -123,7 +124,7 @@ public class MapboxMapOptions implements Parcelable { doubleTapGesturesEnabled = in.readByte() != 0; quickZoomGesturesEnabled = in.readByte() != 0; - apiBaseUrl = in.readString(); + apiBaseUri = in.readString(); textureMode = in.readByte() != 0; translucentTextureSurface = in.readByte() != 0; prefetchesTiles = in.readByte() != 0; @@ -148,8 +149,16 @@ public class MapboxMapOptions implements Parcelable { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.mapbox_MapView, 0, 0); try { mapboxMapOptions.camera(new CameraPosition.Builder(typedArray).build()); + + // deprecated mapboxMapOptions.apiBaseUrl(typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUrl)); + String baseUri = typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUri); + if (!TextUtils.isEmpty(baseUri)) { + // override deprecated property if a value of the new type was provided + mapboxMapOptions.apiBaseUri(baseUri); + } + mapboxMapOptions.zoomGesturesEnabled( typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiZoomGestures, true)); mapboxMapOptions.scrollGesturesEnabled( @@ -246,10 +255,24 @@ public class MapboxMapOptions implements Parcelable { * * @param apiBaseUrl The base of our API endpoint * @return This + * @deprecated use {@link #apiBaseUri} instead */ + @Deprecated @NonNull public MapboxMapOptions apiBaseUrl(String apiBaseUrl) { - this.apiBaseUrl = apiBaseUrl; + this.apiBaseUri = apiBaseUrl; + return this; + } + + /** + * Specifies the URI used for API endpoint. + * + * @param apiBaseUri The base of our API endpoint + * @return This + */ + @NonNull + public MapboxMapOptions apiBaseUri(String apiBaseUri) { + this.apiBaseUri = apiBaseUri; return this; } @@ -660,9 +683,20 @@ public class MapboxMapOptions implements Parcelable { * Get the current configured API endpoint base URL. * * @return Base URL to be used API endpoint. + * @deprecated use {@link #getApiBaseUri()} instead */ + @Deprecated public String getApiBaseUrl() { - return apiBaseUrl; + return apiBaseUri; + } + + /** + * Get the current configured API endpoint base URI. + * + * @return Base URI to be used API endpoint. + */ + public String getApiBaseUri() { + return apiBaseUri; } /** @@ -953,7 +987,7 @@ public class MapboxMapOptions implements Parcelable { dest.writeByte((byte) (doubleTapGesturesEnabled ? 1 : 0)); dest.writeByte((byte) (quickZoomGesturesEnabled ? 1 : 0)); - dest.writeString(apiBaseUrl); + dest.writeString(apiBaseUri); dest.writeByte((byte) (textureMode ? 1 : 0)); dest.writeByte((byte) (translucentTextureSurface ? 1 : 0)); dest.writeByte((byte) (prefetchesTiles ? 1 : 0)); @@ -1044,7 +1078,7 @@ public class MapboxMapOptions implements Parcelable { return false; } - if (apiBaseUrl != null ? !apiBaseUrl.equals(options.apiBaseUrl) : options.apiBaseUrl != null) { + if (apiBaseUri != null ? !apiBaseUri.equals(options.apiBaseUri) : options.apiBaseUri != null) { return false; } if (prefetchesTiles != options.prefetchesTiles) { @@ -1095,7 +1129,7 @@ public class MapboxMapOptions implements Parcelable { result = 31 * result + (zoomGesturesEnabled ? 1 : 0); result = 31 * result + (doubleTapGesturesEnabled ? 1 : 0); result = 31 * result + (quickZoomGesturesEnabled ? 1 : 0); - result = 31 * result + (apiBaseUrl != null ? apiBaseUrl.hashCode() : 0); + result = 31 * result + (apiBaseUri != null ? apiBaseUri.hashCode() : 0); result = 31 * result + (textureMode ? 1 : 0); result = 31 * result + (translucentTextureSurface ? 1 : 0); result = 31 * result + (prefetchesTiles ? 1 : 0); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java index 66038e4d45..7692c1a9f2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java @@ -102,10 +102,10 @@ interface NativeMap { // Style API // - void setStyleUrl(String url); + void setStyleUri(String url); @NonNull - String getStyleUrl(); + String getStyleUri(); void setStyleJson(String newStyleJson); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index 4e774d9f2c..fc68a408fa 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -171,8 +171,8 @@ final class NativeMapView implements NativeMap { } @Override - public void setStyleUrl(String url) { - if (checkState("setStyleUrl")) { + public void setStyleUri(String url) { + if (checkState("setStyleUri")) { return; } nativeSetStyleUrl(url); @@ -180,8 +180,8 @@ final class NativeMapView implements NativeMap { @Override @NonNull - public String getStyleUrl() { - if (checkState("getStyleUrl")) { + public String getStyleUri() { + if (checkState("getStyleUri")) { return ""; } return nativeGetStyleUrl(); 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 c8f7ee6978..07e0daef54 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 @@ -59,11 +59,24 @@ public class Style { * Returns the current style url. * * @return the style url + * @deprecated use {@link #getUri()} instead */ @NonNull + @Deprecated public String getUrl() { validateState("getUrl"); - return nativeMap.getStyleUrl(); + return nativeMap.getStyleUri(); + } + + /** + * Returns the current style uri. + * + * @return the style uri + */ + @NonNull + public String getUri() { + validateState("getUri"); + return nativeMap.getStyleUri(); } /** @@ -600,7 +613,7 @@ public class Style { private final List<ImageWrapper> images = new ArrayList<>(); private TransitionOptions transitionOptions; - private String styleUrl; + private String styleUri; private String styleJson; /** @@ -637,17 +650,60 @@ public class Style { * @param url The URL of the map style * @return this * @see Style + * @deprecated use {@link #fromUri(String)} instead */ + @Deprecated @NonNull public Builder fromUrl(@NonNull String url) { - this.styleUrl = url; + this.styleUri = url; + return this; + } + + /** + * <p> + * Will loads a new map style asynchronous from the specified URI. + * </p> + * {@code uri} can take the following forms: + * <ul> + * <li>{@code Style#StyleUrl}: load one of the bundled styles in {@link Style}.</li> + * <li>{@code mapbox://styles/<user>/<style>}: + * loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a> + * {@code user} is your username. {@code style} is the ID of your custom + * style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li> + * <li>{@code http://...} or {@code https://...}: + * loads the style over the Internet from any web server.</li> + * <li>{@code asset://...}: + * loads the style from the APK {@code assets/} directory. + * This is used to load a style bundled with your app.</li> + * <li>{@code file://...}: + * loads the style from a file path. This is used to load a style from disk. + * </li> + * </li> + * <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li> + * </ul> + * <p> + * This method is asynchronous and will return before the style finishes loading. + * If you wish to wait for the map to finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener} + * callback or use {@link MapboxMap#setStyle(String, OnStyleLoaded)} instead. + * </p> + * If the style fails to load or an invalid style URI is set, the map view will become blank. + * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback + * will be triggered. + * + * @param uri The URI of the map style + * @return this + * @see Style + */ + @NonNull + public Builder fromUri(@NonNull String uri) { + this.styleUri = uri; return this; } /** * Will load a new map style from a json string. * <p> - * If the style fails to load or an invalid style URL is set, the map view will become blank. + * If the style fails to load or an invalid style URI is set, the map view will become blank. * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback * will be triggered. * </p> @@ -876,8 +932,8 @@ public class Style { return this; } - String getUrl() { - return styleUrl; + String getUri() { + return styleUri; } String getJson() { |