Search in sources :

Example 1 with Source

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

Example 2 with Source

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));
                    }
                }
            }
        }
    }
}
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 3 with Source

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

Aggregations

Source (com.mapbox.mapboxsdk.style.sources.Source)3 VectorSource (com.mapbox.mapboxsdk.style.sources.VectorSource)2 Layer (com.mapbox.mapboxsdk.style.layers.Layer)1 SymbolLayer (com.mapbox.mapboxsdk.style.layers.SymbolLayer)1 GeoJsonSource (com.mapbox.mapboxsdk.style.sources.GeoJsonSource)1