0

谷歌地图有一个函数可以让你检索两点之间的距离:GDirections 类的 getDistance()。

现在,这是 Javascript,所以它只能在页面加载后才能计算。

但是,我的搜索表单能够指示您希望自己与他人之间的最大距离是多少,并且基于此,必须提供搜索结果列表。

由于我不能在 PHP 中使用这个函数,有没有另一种方法可以让我计算地球上 2 点之间的距离?通过放弃街道、邮政编码和城市名称,就像谷歌地图需要的一样。

4

3 回答 3

1

Looks like you want to calculate a Great Circle Distance

Formulas have been discussed here on stackoverflow before.

A point on earth is defined by it's latitude and longitude. If you want to calculate the distance between 2 points on earth by giving up the street, postal code and city name, you will need geo-referene data.

This data is available for free on the internet, but the accuracy and availability differ greatly from region to region. (USA data is of good quality, data for Kenia for example will be harder to come by)

So to answer your question:
Yes, there are other ways to calculate what you want. But they require more work/are more complex than just querying the google API.
You might want tot read: Creating a Store Locator with PHP, MySQL & Google Maps

Hope this points you into the right direction.

于 2009-03-19T17:20:11.000 回答
1

页面包含用于 http 连接的谷歌地图参数列表。通过指定输出参数,您可以选择返回 kml 文件或类似文件,并且可以在任何可以建立 http 连接的语言中使用。

于 2009-03-19T09:44:37.157 回答
0

您可以使用 kml 文件。它是 xml 格式的文件,您可以通过链接接收,就像http://maps.google.com/maps?f=d&hl=en&saddr=<src latitude>,<src longitude>&daddr=<dist latitude>,<dist longitude>&ie=UTF8&0&om=0&output=kml 在接收的文件中一样,您可以解析和总结距离

于 2012-03-01T08:43:10.850 回答