Android 实时更新Mapbox LineString
实时更新Android 实时更新Mapbox LineString,android,mapbox,Android,Mapbox,实时更新LineString源代码的最佳方法是什么?我尝试从mapstyle中删除源代码并重新添加,但是Mapbox SDK抱怨说源代码正在使用 我只是在用户沿着路线前进时更新地图 style.removeSource("line-source") //complains that it is in use style.addSource(GeoJsonSource("line-source", FeatureCollection.fromFeatures
LineString
源代码的最佳方法是什么?我尝试从mapstyle中删除源代码并重新添加,但是Mapbox SDK抱怨说源代码正在使用
我只是在用户沿着路线前进时更新地图
style.removeSource("line-source") //complains that it is in use
style.addSource(GeoJsonSource("line-source",
FeatureCollection.fromFeatures
(listOf(Feature.fromGeometry(LineString.fromLngLats(asPoints)))))) //fails as already exists
最好的方法是更新源的FeatureCollection,而不删除源本身:
GeoJsonSource source=mapboxMap.getSourceAs(“行源”)获取具有的源代码代码>
行字符串
:source.setGeoJson(
FeatureCollection.fromFeature(
Feature.fromGeometry(LineString.fromLngLats(asPoints))
)
);