我在mysql中有折线数据。我想用php来测量它的长度。我已经看过distance matrix api了。但是它需要origin_addresses和destination_addresses,我没有这些值。
我找到了decodePolylineToArray的要点,但当我解码我的折线时,有很多值。如何测量多段线的长度?我使用的是php,但是如果你有另一种语言的方法,我可以把它移植到php。
发布于 2012-12-03 21:01:08
您需要对折线中的每条路径使用哈维正弦公式:http://en.wikipedia.org/wiki/Haversine_formula
对于JS Calculate distance between two points in google maps V3中的手动计算,这是一个很好的示例,但有一种更简单的方法:
google.maps.geometry.spherical.computeDistanceBetween(path.getAt(i), path.getAt(i+1));查看这个示例:使用它的http://www-users.mat.umk.pl/~kaskader/polyline_simple.html。
HTH
https://stackoverflow.com/questions/13682136
复制相似问题