use of com.mapbox.mapboxsdk.style.sources.GeoJsonOptions in project mapbox-navigation-android by mapbox.
the class MapUtils method updateMapSourceFromFeatureCollection.
/**
* Takes a {@link FeatureCollection} and creates a map GeoJson source using the sourceId also
* provided.
*
* @param mapboxMap that the current mapView is using
* @param collection the feature collection to be added to the map style
* @param sourceId the source's id for identifying it when adding layers
* @since 0.8.0
*/
public static void updateMapSourceFromFeatureCollection(@NonNull MapboxMap mapboxMap, @Nullable FeatureCollection collection, @NonNull String sourceId) {
if (collection == null) {
collection = FeatureCollection.fromFeatures(new Feature[] {});
}
GeoJsonSource source = mapboxMap.getSourceAs(sourceId);
if (source == null) {
GeoJsonOptions routeGeoJsonOptions = new GeoJsonOptions().withMaxZoom(16);
GeoJsonSource routeSource = new GeoJsonSource(sourceId, collection, routeGeoJsonOptions);
mapboxMap.addSource(routeSource);
} else {
source.setGeoJson(collection);
}
}
use of com.mapbox.mapboxsdk.style.sources.GeoJsonOptions in project mapbox-plugins-android by mapbox.
the class LocationLayer method addLocationSource.
//
// Source actions
//
private void addLocationSource() {
FeatureCollection emptyFeature = FeatureCollection.fromFeatures(new Feature[] {});
GeoJsonSource locationSource = new GeoJsonSource(LOCATION_SOURCE, emptyFeature, new GeoJsonOptions().withMaxZoom(16));
mapboxMap.addSource(locationSource);
sourceMap.put(LOCATION_SOURCE, locationSource);
}
Aggregations