我想计算两点之间的距离。我用谷歌搜索了它,但我发现的是最短的路径距离,我不想让我想知道两点之间的道路距离。
答案 0 :(得分:2)
您可以使用google maps api for directions
您可以使用带有响应的请愿书作为Json在请求中设置参数。
http:// maps.google.com/maps/api/directions/json?origin=40.484037,-3.673553&destination=40.419508,-3.693466&sensor=false&units=度量
或作为XML
http:// maps.google.com/maps/api/directions/xml?origin=40.484037,-3.673553&destination=40.419508,-3.693466&sensor=false&units=度量
您可以将原点和命运值设置为您想要,行走,骑自行车,驾驶的模式的起点和终点。 ..
然后在指标或帝国中设置单位。
在返回的JSON或XML上,您可以解析所需的信息。
您还可以设置路径点,例如MAPS API上的示例。
在腿TAG上,第一个距离将是两个点之间的总距离。
"legs" : [
{
"distance" : {
"text" : "11,7 km",
"value" : 11661
},
"duration" : {
"text" : "16 min",
"value" : 941
},
您可以立即解析所需的所有信息:)
希望它有所帮助。
答案 1 :(得分:2)
答案 2 :(得分:0)
您可以使用http://maps.google.com/maps?saddr= {start_address}& daddr = {destination_address}
它将提供方向细节以及两个位置之间的距离和时间
http://maps.google.com/maps?saddr=79.7189,72.3414&daddr=66.45,74.6333&ie=UTF8&0&om=0&output=kml