更新时间:2022-12-29 20:25:17
使用谷歌地图路线API 。您需要请求指示通过HTTP。您可以直接从Android或通过自己的服务器做到这一点。
Use the Google Maps Directions API. You'll need to request the directions over HTTP. You can do this directly from Android, or via your own server.
例如,方向从Montreal多伦多:
GET http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false
您最终会得到一些JSON。在路线[]腿[]距离
,你会得到这样一个对象:
You'll end up with some JSON. In routes[].legs[].distance
, you'll get an object like this:
"legs" : [
{
"distance" : {
"text" : "542 km",
"value" : 542389
},
您也可以直接从响应对象获取的折线的信息。
You can also get the polyline information directly from the response object.