(Android) 使用 .geojson 文件在地图上画一条线

(Android) Draw a line on the map using a .geojson file

我正在开发公交应用程序,我需要显示使用的路线。有了这个,我使用了 MapBox 网站,在我以 .geojson 格式导出路线后使用数据集和徽标绘制了一条路线,我想知道我是否可以在 android 上的地图上画一条线来自这个文件,而不是在代码中放置点对点。

是的,LineString 可以使用 Mapbox Maps SDK LineLayer 绘制。

https://github.com/mapbox/mapbox-android-demo/search?q=LineLayer&unscoped_q=LineLayer

您可能会发现这些 Mapbox 演示应用程序示例特别有用和鼓舞人心:

注释插件是画线的另一种选择https://docs.mapbox.com/android/plugins/overview/annotation/. You can use a local file with the Plugin, as seen at https://github.com/mapbox/mapbox-plugins-android/blob/master/app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/LineActivity.java#L89