从Google Maps Distance API将JSON数据读取到网页/ html表单中

问题描述 投票:1回答:1

我是Google Maps Distance API的新手。我正在尝试创建一个使用long和lat计算两点之间距离的表单

<a href="https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=53.487362,-2.227197&destinations=51.516595,-0.129279&key=API_KEY">
click here for distance
</a>

单击链接会给我一个JSON格式的结果页面

l

我如何读取“距离:文本”(209 mi)数据并将其值放入同一页上的<div><input>中]

提前感谢

我是Google Maps Distance API的新手。我正在尝试创建一个使用long和lat

html web-services google-places-api
1个回答
0
投票

看来您需要在客户端上获取并显示此数据,因此您应该使用JavaScript来调用client-side Distance Matrix服务。不是Web服务(称为服务器端)。例如:

© www.soinside.com 2019 - 2024. All rights reserved.