1
從DestinationsService.Route迴應,我想訪問類似下面的lat
和lng
值:DirectionsService.Route - 嘗試存取權限緯度,經度不工作
var latitude0 = routes[0].legs[0].steps[0].start_location.lat;
var longitude0 = routes[0].legs[0].steps[0].start_location.lng;
console.log("var ["+latitude0+","+longitude0+"]");
與查看DestinationsService.Route Firefox的調試JSON響應如下所示:
"routes" : [
{
"bounds" : {...}
},
"copyrights" : "Map data ©2015 Google",
"legs" : [
{
"distance" : {...},
"duration" : {...},
"end_address" : "something",
"end_location" : {...},
"start_address" : "another thing",
"start_location" : {...},
"steps" : [
{
"distance" : {...},
"duration" : {
"text" : "2 mins",
"value" : 104
},
"end_location" : {
"lat" : 14.64548629999999,
"lng" : 21.0152624
},
"html_instructions" : "...",
"polyline" : {
"points" : "..."
},
"start_location" : {
"lat" : 14.64537809999999,
"lng" : 17.9754639
},
"travel_mode" : "DRIVING"
我可以訪問steps[0]
中的所有其他字段和值,如
routes[0].legs[0].steps[0].travel_mode
這給了我 「駕駛」 或
routes[0].legs[0].steps[0].duration.text
這給了我 「2分鐘」。
但當訪問作爲解釋開始LAT和start_location
或end_location
LNG它給了我(這是控制檯打印出來):
var [function(){"use strict"; return a},function(){"use strict";return b}]
我在做什麼錯? 在此先感謝您的幫助。
同樣的問題發生在我身上,沒有谷歌改變些什麼? – user892134