将 JSON 条路线导入 Google 地图 Android activity

Import JSON of directions into a Google Maps Android activity

Google 地图使用 JSON 文件来描述从 A 点到 B 点的方向。

我已经将几个这样的 JSON 存储到一个文本文件中。然后我从文件中获取一些 JSON,并希望将其方向绘制成 Google 地图 Android activity.

我预计已经有一些关于此的功能,但我找不到任何东西,除了解析 JSON 并逐点绘制方向图,这似乎不切实际。

有什么建议吗?非常感谢您的宝贵时间。

我知道您想要类似于 Google 地图 JavaScript API 的 DirectionsRenderer,但在 Google 地图 Android API.

遗憾的是,Google 地图 Android API 目前没有这样的 class。您应该解析 JSON 并自己创建折线。

您可以在 Google 地图中看到添加方向支持的功能请求 Android API:

https://issuetracker.google.com/issues/35822353

欢迎为功能请求加注星标以表达您的兴趣。