mapbox 样式
- styles
- 1. 矢量瓦片加载(VectorSource)
- 2. 栅格瓦片加载(RasterSource)
- 3. 改变地图语种(Language)
- 4. 隐藏显示图层(Visibility)
- 5. 地图上加载图片(ImageSource)
- 6. 时间推移效果
styles
1. 矢量瓦片加载(VectorSource)
VectorSourceActivity
style.addSource(new VectorSource("terrain-data", "mapbox://mapbox.mapbox-terrain-v2"));LineLayer terrainData = new LineLayer("terrain-data", "terrain-data");terrainData.setSourceLayer("contour");terrainData.setProperties(lineJoin(Property.LINE_JOIN_ROUND),lineCap(Property.LINE_CAP_ROUND),lineColor(Color.parseColor("#ff69b4")),lineWidth(1.9f));style.addLayer(terrainData);
2. 栅格瓦片加载(RasterSource)
AddWmsSourceActivity
|AdjustLayerOpacityActivity
style.addSource(new RasterSource("web-map-source",new TileSet("tileset", "https://img.nj.gov/imagerywms/Natural2015?bbox={"+ "bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:"+ "3857&transparent=true&width=256&height=256&layers=Natural2015"), 256));// Create a RasterLayer with the source created above and then add the layer to the mapif (style.getLayer("tunnel-street-minor-low") != null) {style.addLayerBelow(new RasterLayer("web-map-layer", "web-map-source"), "tunnel-street-minor-low");} else {style.addLayer(new RasterLayer("web-map-layer", "web-map-source"));}
3. 改变地图语种(Language)
LanguageSwitchActivity
SymbolLayer countryLabelTextSymbolLayer = style.getLayerAs("country-label");countryLabelTextSymbolLayer.setProperties(textField("{name_zh-Hans}"));
4. 隐藏显示图层(Visibility)
ShowHideLayersActivity
if (VISIBLE.equals(layer.getVisibility().getValue())) {layer.setProperties(visibility(NONE));} else {layer.setProperties(visibility(VISIBLE));}
5. 地图上加载图片(ImageSource)
ImageSourceActivity
// Set the latitude and longitude values for the image's four cornersLatLngQuad quad = new LatLngQuad(new LatLng(25.7836, -80.11725),new LatLng(25.783548, -80.1397431334),new LatLng(25.7680, -80.13964),new LatLng(25.76795, -80.11725));// Add an ImageSource to the mapstyle.addSource(new ImageSource(ID_IMAGE_SOURCE, quad, R.drawable.miami_beach));// Create a raster layer and use the imageSource's ID as the layer's data. Then add a RasterLayer to the map.style.addLayer(new RasterLayer(ID_IMAGE_LAYER, ID_IMAGE_SOURCE));
6. 时间推移效果
ImageSourceTimeLapseActivity