use of com.mapbox.mapboxsdk.style.layers.Layer in project androidApp by InspectorIncognito.
the class LocationLayer method addInfoWindowLayer.
private void addInfoWindowLayer(String image) {
Layer infoWindowLayer = new SymbolLayer(LocationLayerConstants.LOCATION_LAYER_INFO_WINDOW, LocationLayerConstants.LOCATION_SOURCE).withProperties(iconImage(image + "-max"), /* set anchor of icon to bottom-left */
iconAnchor("bottom-left"), iconAllowOverlap(true), /* offset icon slightly to match bubble layout */
iconOffset(new Float[] { BusMarker.MAX_DX_OFFSET, BusMarker.MAX_DY_OFFSET })).withFilter(eq(LocationLayerConstants.PROPERTY_MAXIMIZED, true));
addLocationLayerToMap(infoWindowLayer);
}
use of com.mapbox.mapboxsdk.style.layers.Layer in project androidApp by InspectorIncognito.
the class BusStopLayer method setupAllLayers.
public void setupAllLayers(MapboxMap mapboxMap, Context context, String busStopsSource) {
Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.paradero);
mapboxMap.addImage("busStopIcon", icon);
// LOADING LAYER
mapboxMap.addLayer(new CircleLayer(BUS_STOP_LOADING_LAYER_ID, busStopsSource).withProperties(circleRadius(property(BusStopMarker.PROPERTY_LOADING_PROGRESS, exponential(getLoadingAnimationStops()))), PropertyFactory.circlePitchAlignment(Property.CIRCLE_PITCH_ALIGNMENT_MAP), PropertyFactory.iconRotationAlignment(Property.ICON_ROTATION_ALIGNMENT_MAP), circleColor(ContextCompat.getColor(context, R.color.green_button)), circleOpacity(0.6f)).withFilter(eq(BusStopMarker.PROPERTY_LOADING, true)));
// MARKER LAYER
Layer layer = new SymbolLayer(BUS_STOP_MARKER_LAYER_ID, busStopsSource).withProperties(iconImage("busStopIcon"), iconSize(0.8f), /* allows show all icons */
iconAllowOverlap(true), iconOffset(new Float[] { BusStopMarker.MARKER_DX_OFFSET, BusStopMarker.MARKER_DY_OFFSET })).withFilter(eq(BusStopMarker.PROPERTY_SELECTED, false));
layer.setMinZoom(15);
mapboxMap.addLayer(layer);
// SELECTED MARKER LAYER
mapboxMap.addLayer(new SymbolLayer(BUS_STOP_SELECTED_MARKER_LAYER_ID, busStopsSource).withProperties(iconImage("busStopIcon"), iconSize(0.8f), /* allows show all icons */
iconAllowOverlap(true), iconOffset(new Float[] { BusStopMarker.MARKER_DX_OFFSET, BusStopMarker.MARKER_DY_OFFSET })).withFilter(eq(BusStopMarker.PROPERTY_SELECTED, true)));
// MIN INFO WINDOW LAYER
mapboxMap.addLayer(new SymbolLayer(BUS_STOP_INFO_WINDOW_LAYER_ID_MIN, busStopsSource).withProperties(/* show image with id title based on the value of the maximized feature property */
iconImage("{ID}-min"), /* set anchor of icon to bottom-left */
iconAnchor("bottom-left"), /* offset icon slightly to match bubble layout */
iconOffset(new Float[] { BusStopMarker.MIN_DX_OFFSET, BusStopMarker.MIN_DY_OFFSET })).withFilter(all(eq(BusStopMarker.PROPERTY_SELECTED, true), eq(BusStopMarker.PROPERTY_LOADING, false), eq(BusStopMarker.PROPERTY_MAXIMIZED, false))));
// MAX INFO WINDOW LAYER
mapboxMap.addLayer(new SymbolLayer(BUS_STOP_INFO_WINDOW_LAYER_ID_MAX, busStopsSource).withProperties(/* show image with id title based on the value of the maximized feature property */
iconImage("{ID}-max"), /* set anchor of icon to bottom-left */
iconAnchor("bottom-left"), /* offset icon slightly to match bubble layout */
iconOffset(new Float[] { BusStopMarker.MAX_DX_OFFSET, BusStopMarker.MAX_DY_OFFSET })).withFilter(all(eq(BusStopMarker.PROPERTY_SELECTED, true), eq(BusStopMarker.PROPERTY_LOADING, false), eq(BusStopMarker.PROPERTY_MAXIMIZED, true))));
}
use of com.mapbox.mapboxsdk.style.layers.Layer in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method updatePrimaryRoute.
/**
* When the user switches an alternative route to a primary route, this method alters the
* appearance.
*/
private void updatePrimaryRoute(String layerId, int index) {
Layer layer = mapboxMap.getLayer(layerId);
if (layer != null) {
layer.setProperties(PropertyFactory.lineColor(Function.property(CONGESTION_KEY, categorical(stop("moderate", PropertyFactory.lineColor(index == primaryRouteIndex ? routeModerateColor : alternativeRouteModerateColor)), stop("heavy", PropertyFactory.lineColor(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor)), stop("severe", PropertyFactory.lineColor(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor)))).withDefaultValue(PropertyFactory.lineColor(index == primaryRouteIndex ? routeDefaultColor : alternativeRouteDefaultColor))));
if (index == primaryRouteIndex) {
mapboxMap.removeLayer(layer);
mapboxMap.addLayerBelow(layer, WAYPOINT_LAYER_ID);
}
}
}
use of com.mapbox.mapboxsdk.style.layers.Layer in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method addRouteLayer.
/**
* Add the route layer to the map either using the custom style values or the default.
*/
private void addRouteLayer(String layerId, String sourceId, int index) {
float scale = index == primaryRouteIndex ? routeScale : alternativeRouteScale;
Layer routeLayer = new LineLayer(layerId, sourceId).withProperties(PropertyFactory.lineCap(Property.LINE_CAP_ROUND), PropertyFactory.lineJoin(Property.LINE_JOIN_ROUND), PropertyFactory.lineWidth(Function.zoom(exponential(stop(4f, PropertyFactory.lineWidth(3f * scale)), stop(10f, PropertyFactory.lineWidth(4f * scale)), stop(13f, PropertyFactory.lineWidth(6f * scale)), stop(16f, PropertyFactory.lineWidth(10f * scale)), stop(19f, PropertyFactory.lineWidth(14f * scale)), stop(22f, PropertyFactory.lineWidth(18f * scale))).withBase(1.5f))), PropertyFactory.lineColor(Function.property(CONGESTION_KEY, categorical(stop("moderate", PropertyFactory.lineColor(index == primaryRouteIndex ? routeModerateColor : alternativeRouteModerateColor)), stop("heavy", PropertyFactory.lineColor(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor)), stop("severe", PropertyFactory.lineColor(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor)))).withDefaultValue(PropertyFactory.lineColor(index == primaryRouteIndex ? routeDefaultColor : alternativeRouteDefaultColor))));
MapUtils.addLayerToMap(mapboxMap, routeLayer, belowLayer);
}
use of com.mapbox.mapboxsdk.style.layers.Layer in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method updatePrimaryShieldRoute.
private void updatePrimaryShieldRoute(String layerId, int index) {
Layer layer = mapboxMap.getLayer(layerId);
if (layer != null) {
layer.setProperties(PropertyFactory.lineColor(index == primaryRouteIndex ? routeShieldColor : alternativeRouteShieldColor));
if (index == primaryRouteIndex) {
mapboxMap.removeLayer(layer);
mapboxMap.addLayerBelow(layer, WAYPOINT_LAYER_ID);
}
}
}
Aggregations