com.mapbox.mapboxsdk.style.layers.Property Java Examples
The following examples show how to use
com.mapbox.mapboxsdk.style.layers.Property.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TrafficPlugin.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 6 votes |
static LineLayer getLineLayer(String lineLayerId, float minZoom, Expression filter, Expression lineColorExpression, Expression lineWidthExpression, Expression lineOffsetExpression, Expression lineOpacityExpression) { LineLayer lineLayer = new LineLayer(lineLayerId, TrafficData.SOURCE_ID); lineLayer.setSourceLayer(TrafficData.SOURCE_LAYER); lineLayer.setProperties( lineCap(Property.LINE_CAP_ROUND), lineJoin(Property.LINE_JOIN_ROUND), lineColor(lineColorExpression), lineWidth(lineWidthExpression), lineOffset(lineOffsetExpression) ); if (lineOpacityExpression != null) { lineLayer.setProperties(lineOpacity(lineOpacityExpression)); } lineLayer.setFilter(filter); lineLayer.setMinZoom(minZoom); return lineLayer; }
Example #2
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 6 votes |
@NonNull private MapWayname buildMapWayname(PointF point, SymbolLayer waynameLayer, List<Feature> roads) { String roadName = "roadName"; String[] layerIds = {"streetsLayer"}; WaynameLayoutProvider layoutProvider = mock(WaynameLayoutProvider.class); when(layoutProvider.generateLayoutBitmap(roadName)).thenReturn(mock(Bitmap.class)); MapLayerInteractor layerInteractor = mock(MapLayerInteractor.class); when(waynameLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); when(layerInteractor.retrieveLayerFromId(MAPBOX_WAYNAME_LAYER)).thenReturn(waynameLayer); WaynameFeatureFinder featureInteractor = mock(WaynameFeatureFinder.class); when(featureInteractor.queryRenderedFeatures(point, layerIds)).thenReturn(roads); MapPaddingAdjustor paddingAdjustor = mock(MapPaddingAdjustor.class); MapWayname mapWayname = new MapWayname(layoutProvider, layerInteractor, featureInteractor, paddingAdjustor); mapWayname.updateWaynameQueryMap(true); return mapWayname; }
Example #3
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 6 votes |
private LineLayer createArrowShaftLayer() { LineLayer shaftLayer = (LineLayer) mapboxMap.getLayer(ARROW_SHAFT_LINE_LAYER_ID); if (shaftLayer != null) { return shaftLayer; } return new LineLayer(ARROW_SHAFT_LINE_LAYER_ID, ARROW_SHAFT_SOURCE_ID).withProperties( PropertyFactory.lineColor(color(arrowColor)), PropertyFactory.lineWidth( interpolate(linear(), zoom(), stop(MIN_ARROW_ZOOM, MIN_ZOOM_ARROW_SHAFT_SCALE), stop(MAX_ARROW_ZOOM, MAX_ZOOM_ARROW_SHAFT_SCALE) ) ), PropertyFactory.lineCap(Property.LINE_CAP_ROUND), PropertyFactory.lineJoin(Property.LINE_JOIN_ROUND), PropertyFactory.visibility(NONE), PropertyFactory.lineOpacity( step(zoom(), OPAQUE, stop( ARROW_HIDDEN_ZOOM_LEVEL, TRANSPARENT ) ) ) ); }
Example #4
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 6 votes |
private LineLayer createArrowShaftCasingLayer() { LineLayer shaftCasingLayer = (LineLayer) mapboxMap.getLayer(ARROW_SHAFT_CASING_LINE_LAYER_ID); if (shaftCasingLayer != null) { return shaftCasingLayer; } return new LineLayer(ARROW_SHAFT_CASING_LINE_LAYER_ID, ARROW_SHAFT_SOURCE_ID).withProperties( PropertyFactory.lineColor(color(arrowBorderColor)), PropertyFactory.lineWidth( interpolate(linear(), zoom(), stop(MIN_ARROW_ZOOM, MIN_ZOOM_ARROW_SHAFT_CASING_SCALE), stop(MAX_ARROW_ZOOM, MAX_ZOOM_ARROW_SHAFT_CASING_SCALE) ) ), PropertyFactory.lineCap(Property.LINE_CAP_ROUND), PropertyFactory.lineJoin(Property.LINE_JOIN_ROUND), PropertyFactory.visibility(NONE), PropertyFactory.lineOpacity( step(zoom(), OPAQUE, stop( ARROW_HIDDEN_ZOOM_LEVEL, TRANSPARENT ) ) ) ); }
Example #5
Source File: TrafficPlugin.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * Toggles the visibility of the traffic layers. * * @param visible true for visible, false for none */ public void setVisibility(boolean visible) { this.visible = visible; if (!style.isFullyLoaded()) { // We are in progress of loading a new style return; } Source source = style.getSource(TrafficData.SOURCE_ID); if (source == null) { initialise(); } List<Layer> layers = style.getLayers(); for (Layer layer : layers) { if (layerIds.contains(layer.getId())) { layer.setProperties(visibility(visible ? Property.VISIBLE : Property.NONE)); } } }
Example #6
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 6 votes |
/** * Add the route shield layer to the map either using the custom style values or the default. */ private void addRouteShieldLayer(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(interpolate( exponential(1.5f), zoom(), stop(10f, 7f), stop(14f, 10.5f * scale), stop(16.5f, 15.5f * scale), stop(19f, 24f * scale), stop(22f, 29f * scale) ) ), PropertyFactory.lineColor( index == primaryRouteIndex ? routeShieldColor : alternativeRouteShieldColor) ); MapUtils.addLayerToMap(mapboxMap, routeLayer, belowLayer); }
Example #7
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 6 votes |
@Test public void onUpdateWaynameLayer_layerImageIsAdded() { String roadName = "roadName"; SymbolLayer waynameLayer = mock(SymbolLayer.class); when(waynameLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); MapLayerInteractor layerInteractor = mock(MapLayerInteractor.class); when(layerInteractor.retrieveLayerFromId(MAPBOX_WAYNAME_LAYER)).thenReturn(waynameLayer); Bitmap bitmap = mock(Bitmap.class); WaynameLayoutProvider layoutProvider = mock(WaynameLayoutProvider.class); when(layoutProvider.generateLayoutBitmap(roadName)).thenReturn(bitmap); MapWayname mapWayname = buildMapWayname(layoutProvider, layerInteractor); mapWayname.updateWaynameLayer(roadName, waynameLayer); verify(layerInteractor).addLayerImage(MAPBOX_WAYNAME_ICON, bitmap); }
Example #8
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 6 votes |
@Test public void onUpdateWaynameWithPoint_queryRenderedFeaturesIsCalled() { WaynameLayoutProvider layoutProvider = mock(WaynameLayoutProvider.class); MapLayerInteractor layerInteractor = mock(MapLayerInteractor.class); SymbolLayer waynameLayer = mock(SymbolLayer.class); when(waynameLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); when(layerInteractor.retrieveLayerFromId(MAPBOX_WAYNAME_LAYER)).thenReturn(waynameLayer); WaynameFeatureFinder featureInteractor = mock(WaynameFeatureFinder.class); MapPaddingAdjustor paddingAdjustor = mock(MapPaddingAdjustor.class); String[] layerIds = {"streetsLayer"}; PointF point = mock(PointF.class); MapWayname mapWayname = new MapWayname(layoutProvider, layerInteractor, featureInteractor, paddingAdjustor); mapWayname.updateWaynameVisibility(true, waynameLayer); mapWayname.updateWaynameQueryMap(true); mapWayname.updateWaynameWithPoint(point, waynameLayer); verify(featureInteractor).queryRenderedFeatures(point, layerIds); }
Example #9
Source File: MapLayerInteractorTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void isLayerVisible_visibleReturnsTrue() { SymbolLayer anySymbolOrLineLayer = mock(SymbolLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); when(anySymbolOrLineLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); boolean isVisible = layerInteractor.isLayerVisible("any"); assertTrue(isVisible); }
Example #10
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void toggleHidesLocalCaseLayer() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { trafficPlugin.setVisibility(false); assertTrue(mapboxMap.getStyle().getLayer(Local.CASE_LAYER_ID).getVisibility().getValue().equals(Property.NONE)); } }); }
Example #11
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void toggleHidesSecondaryBaseLayer() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { trafficPlugin.setVisibility(false); assertTrue(mapboxMap.getStyle().getLayer(Secondary.BASE_LAYER_ID).getVisibility().getValue().equals(Property.NONE)); } }); }
Example #12
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void toggleHidesSecondaryCaseLayer() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { trafficPlugin.setVisibility(false); assertTrue(mapboxMap.getStyle().getLayer(Secondary.CASE_LAYER_ID).getVisibility().getValue().equals(Property.NONE)); } }); }
Example #13
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void toggleHidesPrimaryBaseLayer() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { trafficPlugin.setVisibility(false); assertTrue(mapboxMap.getStyle().getLayer(Primary.BASE_LAYER_ID).getVisibility().getValue().equals(Property.NONE)); } }); }
Example #14
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 5 votes |
private void drawWaypointMarkers(@NonNull MapboxMap mapboxMap, @Nullable Drawable originMarker, @Nullable Drawable destinationMarker) { if (originMarker == null || destinationMarker == null) { return; } SymbolLayer waypointLayer = mapboxMap.getLayerAs(WAYPOINT_LAYER_ID); if (waypointLayer == null) { Bitmap bitmap = MapImageUtils.getBitmapFromDrawable(originMarker); mapboxMap.addImage("originMarker", bitmap); bitmap = MapImageUtils.getBitmapFromDrawable(destinationMarker); mapboxMap.addImage("destinationMarker", bitmap); waypointLayer = new SymbolLayer(WAYPOINT_LAYER_ID, WAYPOINT_SOURCE_ID).withProperties( PropertyFactory.iconImage(match( Expression.toString(get("waypoint")), literal("originMarker"), stop("origin", literal("originMarker")), stop("destination", literal("destinationMarker")) ) ), PropertyFactory.iconSize(interpolate( exponential(1.5f), zoom(), stop(22f, 2.8f), stop(12f, 1.3f), stop(10f, 0.8f), stop(0f, 0.6f) )), PropertyFactory.iconPitchAlignment(Property.ANCHOR_MAP), PropertyFactory.iconAllowOverlap(true), PropertyFactory.iconIgnorePlacement(true) ); layerIds.add(WAYPOINT_LAYER_ID); MapUtils.addLayerToMap(mapboxMap, waypointLayer, belowLayer); } }
Example #15
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void onVisibiltySetToTrue_paddingIsAdjusted() { SymbolLayer waynameLayer = mock(SymbolLayer.class); when(waynameLayer.getVisibility()).thenReturn(visibility(Property.NONE)); MapLayerInteractor layerInteractor = mock(MapLayerInteractor.class); when(layerInteractor.retrieveLayerFromId(MAPBOX_WAYNAME_LAYER)).thenReturn(waynameLayer); MapPaddingAdjustor paddingAdjustor = mock(MapPaddingAdjustor.class); MapWayname mapWayname = buildMapWayname(layerInteractor, paddingAdjustor); mapWayname.updateWaynameVisibility(true, waynameLayer); verify(paddingAdjustor).updateTopPaddingWithWayname(); }
Example #16
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void onVisibiltySetToFalse_paddingIsAdjusted() { SymbolLayer waynameLayer = mock(SymbolLayer.class); when(waynameLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); MapLayerInteractor layerInteractor = mock(MapLayerInteractor.class); when(layerInteractor.retrieveLayerFromId(MAPBOX_WAYNAME_LAYER)).thenReturn(waynameLayer); MapPaddingAdjustor paddingAdjustor = mock(MapPaddingAdjustor.class); MapWayname mapWayname = buildMapWayname(layerInteractor, paddingAdjustor); mapWayname.updateWaynameVisibility(false, waynameLayer); verify(paddingAdjustor).updateTopPaddingWithDefault(); }
Example #17
Source File: MapLayerInteractorTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void isLayerVisible_visibleReturnsFalse() { LineLayer anySymbolOrLineLayer = mock(LineLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); when(anySymbolOrLineLayer.getVisibility()).thenReturn(visibility(Property.NONE)); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); boolean isVisible = layerInteractor.isLayerVisible("any"); assertFalse(isVisible); }
Example #18
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void toggleHidesTrunkBaseLayer() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { trafficPlugin.setVisibility(false); assertTrue(mapboxMap.getStyle().getLayer(Trunk.BASE_LAYER_ID).getVisibility().getValue().equals(Property.NONE)); } }); }
Example #19
Source File: MapWayname.java From graphhopper-navigation-android with MIT License | 5 votes |
private void createWaynameIcon(String wayname, Layer waynameLayer) { boolean isVisible = waynameLayer.getVisibility().getValue().contentEquals(Property.VISIBLE); if (isVisible) { Bitmap waynameLayoutBitmap = layoutProvider.generateLayoutBitmap(wayname); if (waynameLayoutBitmap != null) { layerInteractor.addLayerImage(MAPBOX_WAYNAME_ICON, waynameLayoutBitmap); waynameLayer.setProperties(iconImage(MAPBOX_WAYNAME_ICON)); } } }
Example #20
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void toggleHidesLocalBaseLayer() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { trafficPlugin.setVisibility(false); assertTrue(mapboxMap.getStyle().getLayer(Local.BASE_LAYER_ID).getVisibility().getValue().equals(Property.NONE)); } }); }
Example #21
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void motorWayCaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(MotorWay.CASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #22
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void motorWayBaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(MotorWay.BASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #23
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void trunkCaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Primary.CASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #24
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void trunkBaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Primary.BASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #25
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void primaryCaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Primary.CASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #26
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void primaryBaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Primary.BASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #27
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void secondaryCaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Secondary.CASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #28
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void secondaryBaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Secondary.BASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #29
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void localCaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Local.CASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }
Example #30
Source File: TrafficPluginTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void localBaseLayerVisible() throws Exception { executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() { @Override public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) { assertTrue(mapboxMap.getStyle().getLayer(Local.BASE_LAYER_ID).getVisibility().getValue().equals(Property.VISIBLE)); } }); }