com.mapbox.mapboxsdk.style.layers.SymbolLayer Java Examples
The following examples show how to use
com.mapbox.mapboxsdk.style.layers.SymbolLayer.
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: ProgramEventDetailActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void setLayer(Style style) { SymbolLayer symbolLayer = new SymbolLayer("POINT_LAYER", "events").withProperties( PropertyFactory.iconImage("ICON_ID"), iconAllowOverlap(true), iconOffset(new Float[]{0f, -9f}) ); symbolLayer.setMinZoom(0); style.addLayer(symbolLayer); if (featureType != FeatureType.POINT) style.addLayerBelow(new FillLayer("POLYGON_LAYER", "events").withProperties( fillColor( ColorUtils.getPrimaryColorWithAlpha(this, ColorUtils.ColorType.PRIMARY_LIGHT, 150f) ) ), "settlement-label" ); }
Example #2
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 6 votes |
@Test public void onRoadsReturnedFromQuery_layoutIconAdded() { String roadName = "roadName"; PointF point = mock(PointF.class); SymbolLayer waynameLayer = mock(SymbolLayer.class); List<Feature> roads = new ArrayList<>(); Feature road = mock(Feature.class); when(road.hasNonNullValueForProperty("name")).thenReturn(true); when(road.getStringProperty("name")).thenReturn(roadName); roads.add(road); WaynameLayoutProvider layoutProvider = mock(WaynameLayoutProvider.class); when(layoutProvider.generateLayoutBitmap(roadName)).thenReturn(mock(Bitmap.class)); MapWayname mapWayname = buildMapWayname(point, layoutProvider, waynameLayer, roads); mapWayname.updateWaynameVisibility(true, waynameLayer); mapWayname.updateWaynameWithPoint(point, waynameLayer); verify(layoutProvider, times(1)).generateLayoutBitmap(roadName); }
Example #3
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 #4
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 6 votes |
@Test public void onRoadsReturnedFromQuery_layoutProviderGeneratesBitmap() { String roadName = "roadName"; PointF point = mock(PointF.class); SymbolLayer waynameLayer = mock(SymbolLayer.class); List<Feature> roads = new ArrayList<>(); Feature road = mock(Feature.class); when(road.hasNonNullValueForProperty("name")).thenReturn(true); when(road.getStringProperty("name")).thenReturn(roadName); roads.add(road); WaynameLayoutProvider layoutProvider = mock(WaynameLayoutProvider.class); when(layoutProvider.generateLayoutBitmap(roadName)).thenReturn(mock(Bitmap.class)); MapWayname mapWayname = buildMapWayname(point, layoutProvider, waynameLayer, roads); mapWayname.updateWaynameVisibility(true, waynameLayer); mapWayname.updateWaynameWithPoint(point, waynameLayer); verify(layoutProvider).generateLayoutBitmap(roadName); }
Example #5
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 6 votes |
/** * Iterate through map style layers backwards till the first not-symbol layer is found. */ private void placeRouteBelow() { if (belowLayer == null || belowLayer.isEmpty()) { List<Layer> styleLayers = mapboxMap.getLayers(); if (styleLayers == null) { return; } for (int i = 0; i < styleLayers.size(); i++) { if (!(styleLayers.get(i) instanceof SymbolLayer) // Avoid placing the route on top of the user location layer && !styleLayers.get(i).getId().contains("mapbox-location")) { belowLayer = styleLayers.get(i).getId(); } } } }
Example #6
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 #7
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 #8
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 6 votes |
private void initializeUpcomingManeuverArrow() { arrowShaftGeoJsonSource = (GeoJsonSource) mapboxMap.getSource(ARROW_SHAFT_SOURCE_ID); arrowHeadGeoJsonSource = (GeoJsonSource) mapboxMap.getSource(ARROW_HEAD_SOURCE_ID); LineLayer shaftLayer = createArrowShaftLayer(); LineLayer shaftCasingLayer = createArrowShaftCasingLayer(); SymbolLayer headLayer = createArrowHeadLayer(); SymbolLayer headCasingLayer = createArrowHeadCasingLayer(); if (arrowShaftGeoJsonSource == null && arrowHeadGeoJsonSource == null) { initializeArrowShaft(); initializeArrowHead(); addArrowHeadIcon(); addArrowHeadIconCasing(); mapboxMap.addLayerBelow(shaftCasingLayer, LAYER_ABOVE_UPCOMING_MANEUVER_ARROW); mapboxMap.addLayerAbove(headCasingLayer, shaftCasingLayer.getId()); mapboxMap.addLayerAbove(shaftLayer, headCasingLayer.getId()); mapboxMap.addLayerAbove(headLayer, shaftLayer.getId()); } initializeArrowLayers(shaftLayer, shaftCasingLayer, headLayer, headCasingLayer); }
Example #9
Source File: NavigationMapboxMap.java From graphhopper-navigation-android with MIT License | 6 votes |
private SymbolLayer createWaynameLayer() { return new SymbolLayer(MAPBOX_WAYNAME_LAYER, MAPBOX_LOCATION_SOURCE) .withProperties( iconAllowOverlap(true), iconIgnorePlacement(true), iconSize( interpolate(exponential(1f), zoom(), stop(0f, 0.6f), stop(18f, 1.2f) ) ), iconAnchor(ICON_ANCHOR_TOP), iconOffset(WAYNAME_OFFSET), iconRotationAlignment(ICON_ROTATION_ALIGNMENT_VIEWPORT) ); }
Example #10
Source File: PolygonContainer.java From AirMapSDK-Android with Apache License 2.0 | 6 votes |
public boolean checkForIntersections() { List<LatLng> points = PointMath.findIntersections(path); if (points.isEmpty()) { return false; } List<Point> intersections = latLngsToPositions(points); if (map.getStyle().getLayer(INTERSECTION_LAYER) == null) { Source intersectionSource = new GeoJsonSource(INTERSECTION_SOURCE, Feature.fromGeometry(MultiPoint.fromLngLats(intersections))); map.getStyle().addSource(intersectionSource); Layer intersectionLayer = new SymbolLayer(INTERSECTION_LAYER, INTERSECTION_SOURCE) .withProperties(PropertyFactory.iconImage(INTERSECTION_IMAGE)); map.getStyle().addLayer(intersectionLayer); } else { GeoJsonSource intersectionsSource = map.getStyle().getSourceAs(INTERSECTION_SOURCE); intersectionsSource.setGeoJson(Feature.fromGeometry(MultiPoint.fromLngLats(intersections))); } return true; }
Example #11
Source File: MapDataManager.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
private void initLastPositionLayer() { GeoJsonSource lastPositionSource = new GeoJsonSource(LAST_POSITION_SOURCE); mapboxStyle.addSource(lastPositionSource); Expression markerSize = switchCase(toBool(get(MARKER_SELECTED)), literal(1.75f), literal(1.25f)); mapboxStyle.addLayerBelow(new SymbolLayer(LAST_POSITION_LAYER, LAST_POSITION_SOURCE).withProperties( iconImage(get(LAST_POSITION_ICON)), /* all info window and marker image to appear at the same time*/ iconAllowOverlap(true), iconIgnorePlacement(true), iconSize(markerSize), textField(get(LAST_POSITION_LABEL)), textAnchor(TEXT_ANCHOR_TOP), textOffset(new Float[]{0.0f, 1.0f}), textAllowOverlap(true), textIgnorePlacement(true) ).withFilter(filterProvider.getTimeFilter()), INFO_WINDOW_LAYER); }
Example #12
Source File: LocalizationPlugin.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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; if (!style.isFullyLoaded()) { // We are in progress of loading a new style return; } List<Layer> layers = style.getLayers(); for (Source source : style.getSources()) { if (sourceIsFromMapbox(source)) { boolean isStreetsV8 = sourceIsStreetsV8(source); for (Layer layer : layers) { if (layer instanceof SymbolLayer) { PropertyValue<?> textFieldProperty = ((SymbolLayer) layer).getTextField(); if (textFieldProperty.isExpression()) { if (isStreetsV8) { convertExpressionV8(mapLocale, layer, textFieldProperty); } else { boolean isStreetsV7 = sourceIsStreetsV7(source); convertExpression(mapLocale, layer, textFieldProperty, isStreetsV7); } } } } } else { String url = null; if (source instanceof VectorSource) { url = ((VectorSource) source).getUrl(); } if (url == null) { url = "not found"; } Timber.d("The %s (%s) source is not based on Mapbox Vector Tiles. Supported sources:\n %s", source.getId(), url, SUPPORTED_SOURCES); } } }
Example #13
Source File: TrafficPlugin.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 = style.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; }
Example #14
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@NonNull private MapWayname buildMapWayname(PointF point, WaynameLayoutProvider layoutProvider, SymbolLayer waynameLayer, List<Feature> roads) { String[] layerIds = {"streetsLayer"}; 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 #15
Source File: MapStyleController.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
@Override public void onDidFinishLoadingStyle() { // Adjust the background overlay opacity to improve map visually on Android BackgroundLayer backgroundLayer = map.getMap().getStyle().getLayerAs("background-overlay"); if (backgroundLayer != null) { if (currentTheme == MappingService.AirMapMapTheme.Light || currentTheme == MappingService.AirMapMapTheme.Standard) { backgroundLayer.setProperties(PropertyFactory.backgroundOpacity(0.95f)); } else if (currentTheme == MappingService.AirMapMapTheme.Dark) { backgroundLayer.setProperties(PropertyFactory.backgroundOpacity(0.9f)); } } try { mapStyle = new MapStyle(map.getMap().getStyle().getJson()); } catch (JSONException e) { Timber.e(e, "Failed to parse style json"); } // change labels to local if device is not in english if (!Locale.ENGLISH.getLanguage().equals(Locale.getDefault().getLanguage())) { for (Layer layer : map.getMap().getStyle().getLayers()) { if (layer instanceof SymbolLayer && (layer.getId().contains("label") || layer.getId().contains("place") || layer.getId().contains("poi"))) { //layer.setProperties(PropertyFactory.textField("{name}")); // TODO: 2020-01-15 Need to do more investigation as to why removing this line fixes map labelling issue. } } } callback.onMapStyleLoaded(); }
Example #16
Source File: MapStyleController.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
public void hideInactiveAirspace(){ Expression hasActive = Expression.has("active"); Expression activeIsTrue = Expression.eq(Expression.get("active"), true); Expression active = Expression.all(hasActive, activeIsTrue); map.getMap().getStyle(style -> { for(Layer layer : Objects.requireNonNull(style.getLayers())){ if(layer.getId().contains("airmap")){ if(layer instanceof FillLayer){ if(((FillLayer) layer).getFilter() != null){ ((FillLayer) layer).setFilter(Expression.any(((FillLayer) layer).getFilter(), active)); } else { ((FillLayer) layer).setFilter(active); } } else if (layer instanceof LineLayer){ if(((LineLayer) layer).getFilter() != null){ ((LineLayer) layer).setFilter(Expression.any(((LineLayer) layer).getFilter(), active)); } else { ((LineLayer) layer).setFilter(active); } } else if(layer instanceof SymbolLayer){ if(((SymbolLayer) layer).getFilter() != null){ ((SymbolLayer) layer).setFilter(Expression.any(((SymbolLayer) layer).getFilter(), active)); } else { ((SymbolLayer) layer).setFilter(active); } } else { Timber.e("Unknown layer"); } } } }); }
Example #17
Source File: MapDataManager.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
private void initInfoWindowLayer() { Expression iconOffset = switchCase( toBool(get(LAST_LOCATION)), literal(new Float[] {-2f, -25f}), literal(new Float[] {-2f, -20f})); GeoJsonSource infoWindowSource = new GeoJsonSource(INFO_WINDOW_SRC); mapboxStyle.addSource(infoWindowSource); mapboxStyle.addLayer(new SymbolLayer(INFO_WINDOW_LAYER, INFO_WINDOW_SRC).withProperties( iconImage(INFO_WINDOW_ID), iconAnchor(ICON_ANCHOR_BOTTOM_LEFT), /* all info window and marker image to appear at the same time*/ iconAllowOverlap(true), /* offset the info window to be above the marker */ iconOffset(iconOffset) )); }
Example #18
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void onVisibiltySetToTrue_isVisibleReturnsTrue() { 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); assertTrue(mapWayname.isVisible()); }
Example #19
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void onVisibiltySetToFalse_isVisibleReturnsFalse() { 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); assertFalse(mapWayname.isVisible()); }
Example #20
Source File: SearchTEActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void setLayer(Style style) { SymbolLayer symbolLayer = new SymbolLayer("POINT_LAYER", "teis").withProperties( PropertyFactory.iconImage(get("teiImage")), iconOffset(new Float[]{0f, -25f}), iconAllowOverlap(true), textAllowOverlap(true) ); symbolLayer.setFilter(eq(literal("$type"), literal("Point"))); style.addLayer(symbolLayer); if (featureType != FeatureType.POINT) { style.addLayerBelow(new FillLayer("POLYGON_LAYER", "teis") .withProperties( fillColor( ColorUtils.getPrimaryColorWithAlpha(this, ColorUtils.ColorType.PRIMARY_LIGHT, 150f) )) .withFilter(eq(literal("$type"), literal("Polygon"))), "POINT_LAYER" ); style.addLayerAbove(new LineLayer("POLYGON_BORDER_LAYER", "teis") .withProperties( lineColor( ColorUtils.getPrimaryColor(this, ColorUtils.ColorType.PRIMARY_DARK) ), lineWidth(2f)) .withFilter(eq(literal("$type"), literal("Polygon"))), "POLYGON_LAYER" ); } }
Example #21
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 #22
Source File: MapWaynameTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void onFeatureWithoutNamePropertyReturned_updateIsIgnored() { PointF point = mock(PointF.class); SymbolLayer waynameLayer = mock(SymbolLayer.class); List<Feature> roads = new ArrayList<>(); Feature road = mock(Feature.class); roads.add(road); MapWayname mapWayname = buildMapWayname(point, waynameLayer, roads); mapWayname.updateWaynameWithPoint(point, waynameLayer); verify(waynameLayer, times(0)).setProperties(any(PropertyValue.class)); }
Example #23
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 #24
Source File: MapLayerInteractorTest.java From graphhopper-navigation-android with MIT License | 5 votes |
@Test public void updateLayerVisibility_visibilityIsNotSet() { SymbolLayer anySymbolOrLineLayer = mock(SymbolLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); layerInteractor.updateLayerVisibility(true, "random"); verify(anySymbolOrLineLayer, times(0)).setProperties(any(PropertyValue.class)); }
Example #25
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 #26
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 5 votes |
private void initializeArrowLayers(LineLayer shaftLayer, LineLayer shaftCasingLayer, SymbolLayer headLayer, SymbolLayer headCasingLayer) { arrowLayers = new ArrayList<>(); arrowLayers.add(shaftCasingLayer); arrowLayers.add(shaftLayer); arrowLayers.add(headCasingLayer); arrowLayers.add(headLayer); }
Example #27
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 5 votes |
private SymbolLayer createArrowHeadCasingLayer() { SymbolLayer headCasingLayer = (SymbolLayer) mapboxMap.getLayer(ARROW_HEAD_CASING_LAYER_ID); if (headCasingLayer != null) { return headCasingLayer; } return new SymbolLayer(ARROW_HEAD_CASING_LAYER_ID, ARROW_HEAD_SOURCE_ID).withProperties( PropertyFactory.iconImage(ARROW_HEAD_ICON_CASING), iconAllowOverlap(true), iconIgnorePlacement(true), PropertyFactory.iconSize(interpolate( linear(), zoom(), stop(MIN_ARROW_ZOOM, MIN_ZOOM_ARROW_HEAD_CASING_SCALE), stop(MAX_ARROW_ZOOM, MAX_ZOOM_ARROW_HEAD_CASING_SCALE) )), PropertyFactory.iconOffset(ARROW_HEAD_CASING_OFFSET), PropertyFactory.iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP), PropertyFactory.iconRotate(get(ARROW_BEARING)), PropertyFactory.visibility(NONE), PropertyFactory.iconOpacity( step(zoom(), OPAQUE, stop( ARROW_HIDDEN_ZOOM_LEVEL, TRANSPARENT ) ) ) ); }
Example #28
Source File: NavigationMapRoute.java From graphhopper-navigation-android with MIT License | 5 votes |
private SymbolLayer createArrowHeadLayer() { SymbolLayer headLayer = (SymbolLayer) mapboxMap.getLayer(ARROW_HEAD_LAYER_ID); if (headLayer != null) { return headLayer; } return new SymbolLayer(ARROW_HEAD_LAYER_ID, ARROW_HEAD_SOURCE_ID) .withProperties( PropertyFactory.iconImage(ARROW_HEAD_ICON), iconAllowOverlap(true), iconIgnorePlacement(true), PropertyFactory.iconSize(interpolate(linear(), zoom(), stop(MIN_ARROW_ZOOM, MIN_ZOOM_ARROW_HEAD_SCALE), stop(MAX_ARROW_ZOOM, MAX_ZOOM_ARROW_HEAD_SCALE) ) ), PropertyFactory.iconOffset(ARROW_HEAD_OFFSET), PropertyFactory.iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP), PropertyFactory.iconRotate(get(ARROW_BEARING)), PropertyFactory.visibility(NONE), PropertyFactory.iconOpacity( step(zoom(), OPAQUE, stop( ARROW_HIDDEN_ZOOM_LEVEL, TRANSPARENT ) ) ) ); }
Example #29
Source File: MapLayerInteractor.java From graphhopper-navigation-android with MIT License | 5 votes |
private String retrieveSourceLayerId(Layer layer) { String sourceIdentifier; if (layer instanceof LineLayer) { sourceIdentifier = ((LineLayer) layer).getSourceLayer(); } else { sourceIdentifier = ((SymbolLayer) layer).getSourceLayer(); } return sourceIdentifier; }
Example #30
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(); }