寻找像oodle.com最近的城市 [英] Finding nearest city like oodle.com

查看:102
本文介绍了寻找像oodle.com最近的城市的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我试图开发一个将显示用户列表的应用程序。该网站应检测用户的位置(我正在使用maxmind api),然后在用户指定的半径范围内显示用户位置+城市的列表。



我该怎么办这个? MaxMind API可以让我通过IP地址检测用户的城市,但是我怎样才能找到附近的城市?



参考网站:www.oodle.com(您也可以手动更改城市+半径)。/ b>

Sanguine

解决方案

存储和比较纬度和经度,这是具体的位置而不是不明确的名称。 MaxMind的所有GeoIP数据库都提供它们。快速谷歌搜索应该为您提供计算地球上各点之间距离的数学运算。



如果您确实想要查找附近的城市, ,那么你需要一个数据库将城市映射到位置。 MaxMind再一次提供了它的所有数据库。转到他们的网站,转到有关您购买或下载的数据库的页面,并查看将CSV格式插入SQL数据库的说明。这会让你了解每个城市的经纬度。然后,Google搜索会再次为您提供计算SQL查询中地球上两点(纬度/长度对)之间距离的算术。通过这种计算来获得最近的城市。



对不起,只给你建议而不是代码,但是你需要做很多小事情建立这个网站。


So, I am trying to develop an application that will display user listings. The site should detect user location (I am using maxmind api for that) and then show listsings from user's location + cities within a user-specified radius.

How do I do this? MaxMind API lets me detect user's city by IP address but how do I find nearby cities?

Reference site: www.oodle.com (you can also manually change city+radius).

Sanguine

解决方案

Rather than store and compare cities, store and compare latitudes and longitudes, which are concrete locations rather than ambiguous names. All of MaxMind's GeoIP databases provide them. A quick Google search should provide you the math to calculate distances between points on the earth.

If you actually want to find nearby cities, not nearby users as you've said, then you need a database mapping cities to locations. Again, MaxMind provides this with all their databases. Go to their website, go to the page about the database you purchased or downloaded, and look at the instructions for inserting the CSV format into a SQL database. That'll get you the latitude and longitude of each city. Then, again, a Google search will provide you the math to calculate the distance between two points on the earth (lat/long pairs) in a SQL query. Order by that calculation to get the nearest cities.

Sorry to give you only advice rather than code, but there's a lot of little things you've just gotta do yourself to build this site.

这篇关于寻找像oodle.com最近的城市的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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