Skip to main content
 首页 » 编程设计

javascript之谷歌地图 API V3 : How show the direction from a point A to point B (Blue line)

2024年02月27日30mate10pro

我的数据库中有 2 个点的纬度和经度,我希望我的 Google map 显示从 A 点到 B 点的路线...

就像我们看到的 here (谷歌地图路线)

如何在 map 上绘制方向线?

请您参考如下方法:

使用directions service Google map API v3。它与 Directions API 基本相同,但很好地封装在 Google Maps API 中,这也提供了在 map 上轻松呈现路线的便捷方法。

有关在 map 上渲染方向路线的信息和示例可以在 rendering directions section 中找到。 Google Maps API v3 文档。