use of com.mapbox.mapboxsdk.style.layers.Layer in project mapbox-plugins-android by mapbox.
the class TrafficPlugin method setVisibility.
/**
* Toggles the visibility of the traffic layers.
*
* @param visible true for visible, false for none
*/
public void setVisibility(boolean visible) {
this.visible = visible;
List<Layer> layers = mapboxMap.getLayers();
for (Layer layer : layers) {
if (layerIds.contains(layer.getId())) {
layer.setProperties(visibility(visible ? Property.VISIBLE : Property.NONE));
}
}
}
use of com.mapbox.mapboxsdk.style.layers.Layer in project mapbox-plugins-android by mapbox.
the class TrafficPlugin method placeLayerBelow.
/**
* Attempts to find the layer which the traffic should be placed below. Depending on the style, this might not always
* be accurate.
*/
private String placeLayerBelow() {
if (belowLayer == null || belowLayer.isEmpty()) {
List<Layer> styleLayers = mapboxMap.getLayers();
Layer layer;
for (int i = styleLayers.size() - 1; i >= 0; i--) {
layer = styleLayers.get(i);
if (!(layer instanceof SymbolLayer)) {
return layer.getId();
}
}
}
return belowLayer;
}
use of com.mapbox.mapboxsdk.style.layers.Layer 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.layers.Layer in project androidApp by InspectorIncognito.
the class LocationLayer method addBackgroundLayer.
private void addBackgroundLayer(Drawable backgroundDrawable) {
Layer backgroundLayer = createLayer(LocationLayerConstants.LOCATION_LAYER, LocationLayerConstants.USER_LOCATION_ICON, backgroundDrawable);
if (mapboxMap.getLayerAs(backgroundLayer.getId()) != null) {
return;
}
mapboxMap.addLayerBelow(backgroundLayer, BUS_STOP_MARKER_LAYER_ID);
layerIds.add(backgroundLayer.getId());
}
use of com.mapbox.mapboxsdk.style.layers.Layer in project androidApp by InspectorIncognito.
the class LocationLayer method setLayerVisibility.
void setLayerVisibility(boolean visible) {
List<Layer> layers = mapboxMap.getLayers();
String id;
for (Layer layer : layers) {
id = layer.getId();
if (layerIds.contains(layer.getId())) {
if (id.equals(LocationLayerConstants.LOCATION_LAYER)) {
layer.setProperties(visibility(visible ? Property.VISIBLE : Property.NONE));
}
}
}
}
Aggregations