【发布时间】:2013-06-29 11:44:30
【问题描述】:
使用 Google Maps Android v2,我如何捕捉使用折线或仅连接到街道的点绘制的路线?
我从 Google Play 服务获取位置,但精度通常在 5-10 米左右,所以点不是直接在街道上,而是有点错误。
【问题讨论】:
标签: android google-maps google-maps-android-api-2 google-play-services
使用 Google Maps Android v2,我如何捕捉使用折线或仅连接到街道的点绘制的路线?
我从 Google Play 服务获取位置,但精度通常在 5-10 米左右,所以点不是直接在街道上,而是有点错误。
【问题讨论】:
标签: android google-maps google-maps-android-api-2 google-play-services
一种可能的方法是向Google Directions API 询问作为Location 对象返回给您的两个连续点之间的确切路径。
示例请求:
http://maps.googleapis.com/maps/api/directions/json?origin=37,-96&destination=37,-96.1&sensor=false
请记住,每个用户 (IP) 每天的请求限制为 2500 个,因此您可能还希望限制您的 LocationClient 或 LocationManager 更新。
【讨论】:
您可以查看我写的关于如何调用 Google 路线 API 解析点并将其显示在 Google 地图上的这篇博文指南:
Google maps directions using Google Directions API and Polylines
【讨论】:
我认为您想要的是 Google Roads API 提供的 snapToRoads 方法。您只需要提供折线 LatLng 点,它就会返回一个 JSON 文件,该文件由折线点组成,可以更平滑地捕捉到道路。
【讨论】: