我有一个谷歌 Mpa Json 网址 http://maps.googleapis.com/maps/api/distancematrix/json?&origins=2020%20E%20main%20ST&destinations=100%20E%20Main%20St%20,Edmond,Ok&mode=driving&sensor =假
这给了我
{
"destination_addresses" : [ "100 East Main Street, Edmond, OK 73034, USA" ],
"origin_addresses" : [ "2020 East Main Street, Lamar, AR 72846, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "410 km",
"value" : 409567
},
"duration" : {
"text" : "3 hours 49 mins",
"value" : 13759
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
我正在尝试使用
function callGoogle(inputOrigin, inputDst, inputMode)
{
$.getJSON('http://maps.googleapis.com/maps/api/distancematrix/json?', { origins: inputOrigin, destinations: inputDst, mode: inputMode, sensor: false }, function (data) {
$.each(data, function (i, item) {
console.log(item.rows.elements.distance.text);
});
});
}
但我遇到了错误。我如何使用 jquery 从这个 json 中获取 97.8 或 97766