[android] - use URI instead of URL to enable asset loading
This commit is contained in:
@@ -10,6 +10,7 @@ import com.mapbox.geojson.FeatureCollection;
|
||||
import com.mapbox.geojson.Geometry;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -80,7 +81,7 @@ public class GeoJsonSource extends Source {
|
||||
*/
|
||||
public GeoJsonSource(String id, @Nullable String geoJson, GeoJsonOptions options) {
|
||||
super();
|
||||
if (geoJson == null || geoJson.startsWith("http")) {
|
||||
if (geoJson == null || geoJson.startsWith("http") || geoJson.startsWith("asset") || geoJson.startsWith("file")) {
|
||||
throw new IllegalArgumentException("Expected a raw json body");
|
||||
}
|
||||
initialize(id, options);
|
||||
@@ -92,7 +93,9 @@ public class GeoJsonSource extends Source {
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url remote json file
|
||||
* @deprecated use {@link #GeoJsonSource(String, URI)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public GeoJsonSource(String id, URL url) {
|
||||
super();
|
||||
initialize(id, null);
|
||||
@@ -105,13 +108,40 @@ public class GeoJsonSource extends Source {
|
||||
* @param id the source id
|
||||
* @param url remote json file
|
||||
* @param options options
|
||||
* @deprecated use {@link #GeoJsonSource(String, URI, GeoJsonOptions)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public GeoJsonSource(String id, URL url, GeoJsonOptions options) {
|
||||
super();
|
||||
initialize(id, options);
|
||||
nativeSetUrl(url.toExternalForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GeoJsonSource from a geo json file
|
||||
*
|
||||
* @param id the source id
|
||||
* @param uri unique resource identifier
|
||||
*/
|
||||
public GeoJsonSource(String id, URI uri) {
|
||||
super();
|
||||
initialize(id, null);
|
||||
nativeSetUrl(uri.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GeoJsonSource from a geo json file and non-default GeoJsonOptions
|
||||
*
|
||||
* @param id the source id
|
||||
* @param uri remote json file
|
||||
* @param options options
|
||||
*/
|
||||
public GeoJsonSource(String id, URI uri, GeoJsonOptions options) {
|
||||
super();
|
||||
initialize(id, options);
|
||||
nativeSetUrl(uri.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GeoJsonSource from a FeatureCollection.
|
||||
*
|
||||
@@ -247,22 +277,46 @@ public class GeoJsonSource extends Source {
|
||||
* Updates the url
|
||||
*
|
||||
* @param url the GeoJSON FeatureCollection url
|
||||
* @deprecated use {@link #setUri(URI)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setUrl(@NonNull URL url) {
|
||||
checkThread();
|
||||
setUrl(url.toExternalForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the uri
|
||||
*
|
||||
* @param url the GeoJSON FeatureCollection uri
|
||||
*/
|
||||
public void setUri(@NonNull URI url) {
|
||||
checkThread();
|
||||
setUrl(url.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the url
|
||||
*
|
||||
* @param url the GeoJSON FeatureCollection url
|
||||
* @deprecated use {@link #setUri(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setUrl(String url) {
|
||||
checkThread();
|
||||
nativeSetUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the url
|
||||
*
|
||||
* @param uri the GeoJSON FeatureCollection uri
|
||||
*/
|
||||
public void setUri(String uri) {
|
||||
checkThread();
|
||||
nativeSetUrl(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The url or null
|
||||
*/
|
||||
|
||||
@@ -9,11 +9,11 @@ import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngQuad;
|
||||
import com.mapbox.mapboxsdk.utils.BitmapUtils;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
@@ -45,13 +45,28 @@ public class ImageSource extends Source {
|
||||
* @param id The source id
|
||||
* @param coordinates The Latitude and Longitude of the four corners of the image
|
||||
* @param url remote json file
|
||||
* @deprecated use {@link ImageSource#ImageSource(String, LatLngQuad, URI)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public ImageSource(String id, LatLngQuad coordinates, @NonNull URL url) {
|
||||
super();
|
||||
initialize(id, coordinates);
|
||||
setUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ImageSource from coordinates and an image URL
|
||||
*
|
||||
* @param id The source id
|
||||
* @param coordinates The Latitude and Longitude of the four corners of the image
|
||||
* @param uri json file uri
|
||||
*/
|
||||
public ImageSource(String id, LatLngQuad coordinates, @NonNull URI uri) {
|
||||
super();
|
||||
initialize(id, coordinates);
|
||||
setUri(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ImageSource from coordinates and a bitmap image
|
||||
*
|
||||
@@ -82,7 +97,9 @@ public class ImageSource extends Source {
|
||||
* Updates the source image url
|
||||
*
|
||||
* @param url An Image url
|
||||
* @deprecated use {@link #setUri(URI)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setUrl(@NonNull URL url) {
|
||||
setUrl(url.toExternalForm());
|
||||
}
|
||||
@@ -91,12 +108,33 @@ public class ImageSource extends Source {
|
||||
* Updates the source image url
|
||||
*
|
||||
* @param url An image url
|
||||
* @deprecated use {@link #setUri(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setUrl(String url) {
|
||||
checkThread();
|
||||
nativeSetUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the source image uri
|
||||
*
|
||||
* @param uri An Image url
|
||||
*/
|
||||
public void setUri(@NonNull URI uri) {
|
||||
setUrl(uri.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the source image uri
|
||||
*
|
||||
* @param uri An image uri
|
||||
*/
|
||||
public void setUri(String uri) {
|
||||
checkThread();
|
||||
nativeSetUrl(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the source image to a bitmap
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
@@ -31,32 +32,44 @@ public class RasterDemSource extends Source {
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the source url
|
||||
* @deprecated use {@link #RasterDemSource(String, URI)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public RasterDemSource(String id, URL url) {
|
||||
this(id, url.toExternalForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the raster dem source from an URL
|
||||
* Create the raster dem source from an URI
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the source url
|
||||
* @param uri the source uri
|
||||
*/
|
||||
public RasterDemSource(String id, String url) {
|
||||
public RasterDemSource(String id, URI uri) {
|
||||
this(id, uri.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the raster dem source from an URI
|
||||
*
|
||||
* @param id the source id
|
||||
* @param uri the source uri
|
||||
*/
|
||||
public RasterDemSource(String id, String uri) {
|
||||
super();
|
||||
initialize(id, url, DEFAULT_TILE_SIZE);
|
||||
initialize(id, uri, DEFAULT_TILE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the raster source from an URL with a specific tile size
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the source url
|
||||
* @param uri the source url
|
||||
* @param tileSize the tile size
|
||||
*/
|
||||
public RasterDemSource(String id, String url, int tileSize) {
|
||||
public RasterDemSource(String id, String uri, int tileSize) {
|
||||
super();
|
||||
initialize(id, url, tileSize);
|
||||
initialize(id, uri, tileSize);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,13 +97,24 @@ public class RasterDemSource extends Source {
|
||||
|
||||
/**
|
||||
* @return The url or null
|
||||
* @deprecated use {@link #getUri()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public String getUrl() {
|
||||
checkThread();
|
||||
return nativeGetUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The uri or null
|
||||
*/
|
||||
@Nullable
|
||||
public String getUri() {
|
||||
checkThread();
|
||||
return nativeGetUrl();
|
||||
}
|
||||
|
||||
@Keep
|
||||
protected native void initialize(String layerId, Object payload, int tileSize);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
@@ -29,33 +30,43 @@ public class RasterSource extends Source {
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the source url
|
||||
* @deprecated use {@link #RasterSource(String, URI)} instead
|
||||
*/
|
||||
public RasterSource(String id, URL url) {
|
||||
this(id, url.toExternalForm());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the raster source from an URL
|
||||
* Create the raster source from an URI
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the source url
|
||||
* @param uri the source uri
|
||||
*/
|
||||
public RasterSource(String id, String url) {
|
||||
public RasterSource(String id, URI uri) {
|
||||
this(id, uri.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the raster source from an URI
|
||||
*
|
||||
* @param id the source id
|
||||
* @param uri the source uri
|
||||
*/
|
||||
public RasterSource(String id, String uri) {
|
||||
super();
|
||||
initialize(id, url, DEFAULT_TILE_SIZE);
|
||||
initialize(id, uri, DEFAULT_TILE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the raster source from an URL with a specific tile size
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the source url
|
||||
* @param uri the source url
|
||||
* @param tileSize the tile size
|
||||
*/
|
||||
public RasterSource(String id, String url, int tileSize) {
|
||||
public RasterSource(String id, String uri, int tileSize) {
|
||||
super();
|
||||
initialize(id, url, tileSize);
|
||||
initialize(id, uri, tileSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.style.sources;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -37,20 +38,32 @@ public class VectorSource extends Source {
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the TileJSON resource url
|
||||
* @deprecated use {@link #VectorSource(String, Uri)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public VectorSource(String id, URL url) {
|
||||
this(id, url.toExternalForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a vector source from a remote url
|
||||
* Create a vector source from a uri pointing to a TileJSON resource
|
||||
*
|
||||
* @param id the source id
|
||||
* @param url the url
|
||||
* @param uri the TileJSON resource url
|
||||
*/
|
||||
public VectorSource(String id, String url) {
|
||||
public VectorSource(String id, Uri uri) {
|
||||
this(id, uri.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a vector source from a uri
|
||||
*
|
||||
* @param id the source id
|
||||
* @param uri the uri
|
||||
*/
|
||||
public VectorSource(String id, String uri) {
|
||||
super();
|
||||
initialize(id, url);
|
||||
initialize(id, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,13 +96,24 @@ public class VectorSource extends Source {
|
||||
|
||||
/**
|
||||
* @return The url or null
|
||||
* @deprecated use {@link #getUri()} instead
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public String getUrl() {
|
||||
checkThread();
|
||||
return nativeGetUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The uri or null
|
||||
*/
|
||||
@Nullable
|
||||
public String getUri() {
|
||||
checkThread();
|
||||
return nativeGetUrl();
|
||||
}
|
||||
|
||||
@Keep
|
||||
protected native void initialize(String layerId, Object payload);
|
||||
|
||||
|
||||
@@ -7,38 +7,36 @@ import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.Style;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.Style;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.gte;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.gt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.gt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.gte;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.has;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
|
||||
|
||||
|
||||
/**
|
||||
@@ -87,8 +85,8 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
private void addBusStopSource(Style style) {
|
||||
try {
|
||||
source = new GeoJsonSource(SOURCE_ID, new URL(URL_BUS_ROUTES));
|
||||
} catch (MalformedURLException exception) {
|
||||
source = new GeoJsonSource(SOURCE_ID, new URI(URL_BUS_ROUTES));
|
||||
} catch (URISyntaxException exception) {
|
||||
Timber.e(exception, "That's not an url... ");
|
||||
}
|
||||
style.addSource(source);
|
||||
@@ -140,14 +138,14 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
try {
|
||||
mapboxMap.getStyle().addSource(
|
||||
new GeoJsonSource(SOURCE_ID_CLUSTER,
|
||||
new URL(URL_BUS_ROUTES),
|
||||
new URI(URL_BUS_ROUTES),
|
||||
new GeoJsonOptions()
|
||||
.withCluster(true)
|
||||
.withClusterMaxZoom(14)
|
||||
.withClusterRadius(50)
|
||||
)
|
||||
);
|
||||
} catch (MalformedURLException malformedUrlException) {
|
||||
} catch (URISyntaxException malformedUrlException) {
|
||||
Timber.e(malformedUrlException, "That's not an url... ");
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
|
||||
import com.mapbox.mapboxsdk.utils.BitmapUtils;
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -98,7 +98,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
|
||||
BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_hearing_black_24dp))), true
|
||||
)
|
||||
);
|
||||
} catch (IOException exception) {
|
||||
} catch (URISyntaxException exception) {
|
||||
Timber.e(exception);
|
||||
}
|
||||
|
||||
@@ -133,10 +133,8 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private GeoJsonSource createClusterSource() throws IOException {
|
||||
String earthQuakes = GeoParseUtil.loadStringFromAssets(this, "earthquakes.geojson");
|
||||
FeatureCollection featureCollection = FeatureCollection.fromJson(earthQuakes);
|
||||
return new GeoJsonSource("earthquakes", featureCollection, new GeoJsonOptions()
|
||||
private GeoJsonSource createClusterSource() throws URISyntaxException {
|
||||
return new GeoJsonSource("earthquakes", new URI("asset://earthquakes.geojson"), new GeoJsonOptions()
|
||||
.withCluster(true)
|
||||
.withClusterMaxZoom(14)
|
||||
.withClusterRadius(50)
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.Style;
|
||||
@@ -10,12 +9,11 @@ import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.HeatmapLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.heatmapDensity;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
|
||||
@@ -66,14 +64,14 @@ public class HeatmapLayerActivity extends AppCompatActivity {
|
||||
.withLayerAbove(createHeatmapLayer(), "waterway-label")
|
||||
.withLayerBelow(createCircleLayer(), HEATMAP_LAYER_ID)
|
||||
);
|
||||
} catch (MalformedURLException exception) {
|
||||
} catch (URISyntaxException exception) {
|
||||
Timber.e(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private GeoJsonSource createEarthquakeSource() throws MalformedURLException {
|
||||
return new GeoJsonSource(EARTHQUAKE_SOURCE_ID, new URL(EARTHQUAKE_SOURCE_URL));
|
||||
private GeoJsonSource createEarthquakeSource() throws URISyntaxException {
|
||||
return new GeoJsonSource(EARTHQUAKE_SOURCE_ID, new URI(EARTHQUAKE_SOURCE_URL));
|
||||
}
|
||||
|
||||
private HeatmapLayer createHeatmapLayer() {
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
@@ -12,12 +11,11 @@ import com.mapbox.mapboxsdk.maps.Style;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
|
||||
/**
|
||||
@@ -54,12 +52,12 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR
|
||||
|
||||
mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
|
||||
@Override
|
||||
public void onStyleLoaded(Style style) {
|
||||
public void onStyleLoaded(@NonNull Style style) {
|
||||
// add source
|
||||
try {
|
||||
style.addSource(new GeoJsonSource(ID_GEOJSON_SOURCE, new URL(URL_GEOJSON_SOURCE)));
|
||||
} catch (MalformedURLException malformedUrlException) {
|
||||
Timber.e(malformedUrlException, "Invalid URL");
|
||||
style.addSource(new GeoJsonSource(ID_GEOJSON_SOURCE, new URI(URL_GEOJSON_SOURCE)));
|
||||
} catch (URISyntaxException malformedUriException) {
|
||||
Timber.e(malformedUriException, "Invalid URL");
|
||||
}
|
||||
|
||||
// add layer
|
||||
|
||||
Reference in New Issue
Block a user