计算PHP中地球上两个坐标之间的行驶距离 [英] to calculate driving distance between two coordinates on earth in php

查看:267
本文介绍了计算PHP中地球上两个坐标之间的行驶距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在基于位置的应用程序中工作,我需要在服务器端找到地球上两个位置之间的行驶距离.我正在用php编码Web服务.

Well i am working in a location based app and i need to find driving distance between two location on earth at the server end. i am coding the web service in php.

到目前为止,我可以使用Haversine公式来计算空中距离,但是现在我想计算出行驶距离.

Till now i am able to calculate the aerial distance using the Haversine formula, but now i want to calculate the driving distance.

此问题可能重复,但是我无法找到任何帮助来计算两个坐标"(即纬度和经度)之间的行驶距离",而不是PHP中的地址

There can be possible duplicates for this question, but i was not able to find any help to calculate the "Driving distance" between two "coordinates" ie latitude and longitude instead of addresses in PHP

推荐答案

这应该让您入门...

This should get you started...

$json = file_get_contents('http://maps.google.com/maps/nav?q=from:Buderim,Australia%20to:Brisbane,Australia');

$details = json_decode($json, TRUE);

var_dump($details['Directions']['Distance']['meters']);

这篇关于计算PHP中地球上两个坐标之间的行驶距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆