如何获得Coordiantes作为回应而不是起源& Google Map Distance Matrix API中的目标地址 [英] how to get coordiantes in response instead of origin & destination addresses in Google Map Distance Matrix API
问题描述
我在我的Android应用程序中使用Google距离矩阵api.我通过将起点和终点发送给API来调用Google距离矩阵api.
I'm using google distance matrix api in my android application. I'm calling Google distance matrix api by sending origin and destination to API.
API返回的响应为:
API returns response as:
{
"destination_addresses" : [ "Islamabad, Islamabad Capital Territory, Pakistan" ],
"origin_addresses" : [ "Lahore, Punjab, Pakistan" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "234 mi",
"value" : 376505
},
"duration" : {
"text" : "4 hours 20 mins",
"value" : 15608
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
我想去目的地&原点坐标,而不是位置地址.
I want to get destination & origin coordinates instead of location addresses.
(出于比较的目的,我需要坐标)
(I need coordinates for some comparison purpose)
是否有获取坐标的选项,或者您可以建议其他一些第三方图书馆来获得所需的响应?
Is there an option to get coordinates or can you sugguest some other third party libraries that can get me the desired response.
推荐答案
一旦您获得地址,请使用 GeoCoding Api 再次进行api调用.这个
Once you get address , make another api call with GeoCoding Api.It will return lat long like this
https://maps.googleapis.com/maps/api/geocode/json?address=YOUR_LOCATION&key=YOUR_API_KEY
这篇关于如何获得Coordiantes作为回应而不是起源& Google Map Distance Matrix API中的目标地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!