使用经度和纬度获取最近的位置 [英] Get nearest locations using latitude and longitude
本文介绍了使用经度和纬度获取最近的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张桌子hotspots
id name date
1 foo 2011-06-15 15:10:34
2 bar 2011-07-02 16:45:18
和一张桌子locations
hotspotid zipcode latitude longitude
1 90001 xxxxx xxxxx
2 45802 xxxxx xxxxx
如何使用SQL查询列出附近具有英里数限制的特定纬度和经度的热点?
How can i list the hotspots nearby to a specific latitude and longitude with miles limit using an SQL query?
P.S.我想要一个纯SQL解决方案,但是如果需要的话php是可以的.
P.S. i'd like a pure SQL solution but php is ok if it's needed.
谢谢
推荐答案
首先,最好使用纬度和经度为每个热点确定一个地理位置.您可以使用 Google地理编码API 浏览每条记录并存储经度/纬度.
First you need a geographic location for each hotspot ideally using latitude and longitude. You can use the Google Geocoding API to go through each record and store lat/long.
然后,您可以将附近的热点与此SQL查询进行匹配并按距离排序.
Then you can match nearby hotspots with this SQL query and order by distance.
希望有帮助.
这篇关于使用经度和纬度获取最近的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文