众所周知,mapbox.addMarker()
已过时!
我试图找出使用符号层
我正在使用此代码,它正在为我工作!但是每次我要添加标记时,它都会重新定义地图的样式
代码如下:
//Add Marker to the Map
public void addMarker(@NonNull LatLng point) {
Feature feature = Feature.fromGeometry(Point.fromLngLat(point.getLongitude(),point.getLatitude()));
mapboxMap
.setStyle(new Style.Builder()
.fromUri("mapbox://styles/mapbox/cjf4m44iw0uza2spb3q0a7s41")
.withImage(ICON_ID,marker)
.withSource(new GeoJsonSource(SOURCE_ID,feature))
.withLayer(new SymbolLayer(LAYER_ID,SOURCE_ID)
.withProperties(PropertyFactory.iconImage(ICON_ID),iconAllowOverlap(true),iconIgnorePlacement(true),iconOffset(new Float[]{0f,-9f}))));
}
所以,我想知道在最新MapBox SDK 8.5.0
上是否有正确或更好的方法来添加标记谢谢!