Search in sources :

Example 6 with Layer

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));
        }
    }
}
Also used : LineLayer(com.mapbox.mapboxsdk.style.layers.LineLayer) Layer(com.mapbox.mapboxsdk.style.layers.Layer) SymbolLayer(com.mapbox.mapboxsdk.style.layers.SymbolLayer)

Example 7 with Layer

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;
}
Also used : SymbolLayer(com.mapbox.mapboxsdk.style.layers.SymbolLayer) LineLayer(com.mapbox.mapboxsdk.style.layers.LineLayer) Layer(com.mapbox.mapboxsdk.style.layers.Layer) SymbolLayer(com.mapbox.mapboxsdk.style.layers.SymbolLayer)

Example 8 with Layer

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));
                    }
                }
            }
        }
    }
}
Also used : SymbolLayer(com.mapbox.mapboxsdk.style.layers.SymbolLayer) Layer(com.mapbox.mapboxsdk.style.layers.Layer) Source(com.mapbox.mapboxsdk.style.sources.Source) VectorSource(com.mapbox.mapboxsdk.style.sources.VectorSource)

Example 9 with Layer

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());
}
Also used : Layer(com.mapbox.mapboxsdk.style.layers.Layer) SymbolLayer(com.mapbox.mapboxsdk.style.layers.SymbolLayer)

Example 10 with Layer

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));
            }
        }
    }
}
Also used : Layer(com.mapbox.mapboxsdk.style.layers.Layer) SymbolLayer(com.mapbox.mapboxsdk.style.layers.SymbolLayer)

Aggregations

Layer (com.mapbox.mapboxsdk.style.layers.Layer)12 SymbolLayer (com.mapbox.mapboxsdk.style.layers.SymbolLayer)12 LineLayer (com.mapbox.mapboxsdk.style.layers.LineLayer)6 Bitmap (android.graphics.Bitmap)1 CircleLayer (com.mapbox.mapboxsdk.style.layers.CircleLayer)1 GeoJsonSource (com.mapbox.mapboxsdk.style.sources.GeoJsonSource)1 Source (com.mapbox.mapboxsdk.style.sources.Source)1 VectorSource (com.mapbox.mapboxsdk.style.sources.VectorSource)1