如何从给定城市获取附近的城市?
考虑到距基地城市 50 公里的半径,我需要找到附近的城市。
我的脚本应该是 PHP 的...有没有 API 可以找到它...
请帮助我...
谢谢...
Considering a radius of 50 KM from the base city i need to find the nearby cities .
My script should be in PHP... Is there any API to find it out....
Please please help me...
THanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个很棒的资源:code.google.com/apis/maps/articles /phpsqlsearch.html#findnearsql
基地城市: Lat: 37 Lng: -122
与“Tricker”的解决方案原理相同。
This is a great resource: code.google.com/apis/maps/articles/phpsqlsearch.html#findnearsql
Base city: Lat: 37 Lng: -122
Same principle as the solution from "Tricker".
我写了一种计算坐标之间距离的脚本。当你有 2 个坐标时,你可以这样做:
你必须传入基本城市地理坐标,然后你需要将 cURL 发送到 google 或 yahoo 服务器(取决于你想要哪个地理编码器 api)来获取城市坐标。
现在的问题是你有哪些城市的坐标?如果你没有,你可以购买一个邮政编码区域数据库(然后你可以得到你想要的城市的坐标)。当您获得城市坐标时,您可以对距离进行复杂的计算。之后,您可以查看结果/距离是否大于或小于 50。如果小于,您可以将其作为范围内的城市返回。
这不是几分钟之内就能完成的事情
I wrote a kind off scripts that calculating distances between coordinates. You can do it when you have 2 coordinates:
You have to pass in the base city geo coords, then you need to send a cURL to the google or yahoo server(depends on which geocoder api you wanna you) to get the city coords.
Now its the question from which cities do you have coordinates? if you have none you can buy a zipcode area database(then you can have your coordinates off the city you wanna have). when you have the coords from city, you can run a complicated calculation as result a distance. After that you can look if the result/distance is greater or lesser then 50. if is lesser you can return it as a city in range.
it isn't something you do in a few minutes