use of com.mapbox.mapboxsdk.style.sources.Source in project mapbox-plugins-android by mapbox.
the class TrafficPlugin method updateState.
/**
* Update the state of the traffic plugin.
*/
private void updateState() {
Source source = mapboxMap.getSource(TrafficData.SOURCE_ID);
if (source == null) {
initialise();
return;
}
setVisibility(visible);
}
use of com.mapbox.mapboxsdk.style.sources.Source in project mapbox-plugins-android by mapbox.
the class LocalizationPlugin method setMapLanguage.
/**
* You can pass in a {@link MapLocale} directly into this method which uses the language defined
* in it to represent the language found on the map.
*
* @param mapLocale the {@link MapLocale} object which contains the desired map language
* @since 0.1.0
*/
public void setMapLanguage(@NonNull MapLocale mapLocale) {
this.mapLocale = mapLocale;
List<Layer> layers = mapboxMap.getLayers();
for (Source source : mapboxMap.getSources()) {
if (sourceIsFromMapbox(source)) {
for (Layer layer : layers) {
if (layerHasAdjustableTextField(layer)) {
String textField = ((SymbolLayer) layer).getTextField().getValue();
if (textField != null && (textField.contains("{name") || textField.contains("{abbr}"))) {
textField = textField.replaceAll("[{]((name).*?)[}]", String.format("{%s}", mapLocale.getMapLanguage()));
layer.setProperties(textField(textField));
}
}
}
}
}
}
use of com.mapbox.mapboxsdk.style.sources.Source in project androidApp by InspectorIncognito.
the class UserPlugin method mapStyleFinishedLoading.
/**
* If the location layer was being displayed before the style change, it will need to be displayed in the new style.
*/
@SuppressWarnings({ "MissingPermission" })
void mapStyleFinishedLoading() {
Source source = mapboxMap.getSource(LocationLayerConstants.LOCATION_SOURCE);
if (source == null) {
locationLayer = new LocationLayer(mapView, mapboxMap);
setLocationLayerEnabled(getLocationLayerMode());
} else {
locationLayer.setLayerVisibility(locationLayerMode != LocationLayerMode.NONE);
}
GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
if (locationGeoJsonSource != null) {
locationGeoJsonSource.setGeoJson(previousPoint);
}
}
Aggregations