我开发了下面的代码,通过2个文本区域来获得给定2个城市的距离,并且我想使用以下URl将它们发送到谷歌地图距离矩阵api。我发送这些城市并获得JSON输出文件。但我的问题是如何从该JSON文件中获取特定属性(距离)并在另一个文本字段上显示。使用谷歌地图距离矩阵api得到距离JSON输出
function m() {
var x = document.getElementById("autocomplete").value;
var y = document.getElementById("autocomplete1").value;
var url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=" + x + "&destinations=" + y + "&key=AIzaSyD5KX6VRon6yQ0vu4s6GSnAVzazRWg8wrc";
window.location=url; // this will go to the above url and display the JSON output file on the browser. I dont want that to be shown. just some processing and should display only the distance form that file on a textfield!
}
的JSON输出文件http://pastebin.ca/3318529
请帮助解决这个问题。我是JSON的新手。所以,如果你有任何其他想法告诉我。非常感谢:)
非常感谢。有效 :))) – sheslv