【问题标题】:How to add a polyline in google maps v2 that follows the road for a route如何在谷歌地图v2中添加一条沿着道路的折线
【发布时间】:2013-09-20 01:06:26
【问题描述】:

我想创建一条从 A 点到 B 点的折线,突出显示谷歌地图中的某条路线。我在这里检查过https://developers.google.com/maps/documentation/android/shapes .当我创建一条折线时,它会从点 a 到点 b 绘制一条直线。有没有办法让这条折线跟随街道的路径?

【问题讨论】:

  • 第 1 步:在街道上找到两个端点之间的点。第 2 步:使用第 1 步中的点创建一条折线。
  • 如何在我的端点之间找到街道上的点?
  • @KeithVandagriff 使用Directions API

标签: android google-maps-android-api-2 polyline


【解决方案1】:

在 google maps android v2 中没有方向 api。您必须使用 javascript directions api 获取 json/xml 响应,然后解析输出以获取已编码点的“overview_polyline。您的输入应该是两个点(A TO B) 到方向 api

base_64 编码点 (Google documentation) 应该有您的 lat/lng 用于路线。 这可能会有所帮助 - Link (虽然它使用 android v1 api 作为点,但您可以用 v2 LatLng Point 对象替换它们)

【讨论】:

    猜你喜欢
    • 2013-10-08
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 2013-01-21
    • 2013-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多