简体   繁体   English

从坐标获取位置?

[英]Getting location from coordinates?

I have a script to get a user's coordinates when they go to a certain page, but I need a way to get their approximate location (city, state, country, etc.). 我有一个脚本来获取用户访问某个页面时的坐标,但我需要一种方法来获取他们的大致位置(城市,州,国家等)。 Is there a way I go about doing this server-side (preferrably PHP)? 我有没有办法做这个服务器端(最好是PHP)?

Choices that I have found till now 到目前为止我找到的选择

  1. Google Maps reverse geocoding API 谷歌地图反向地理编码API
  2. Yahoo Geoplanet API Yahoo Geoplanet API
  3. SimpleGeo SimpleGeo
  4. Geonames.org Geonames.org
  5. Bing reverse geocoding API Bing反向地理编码API

All of these expose simple HTTP endpoints for retrieving the address depending on a particular lat/lng combination. 所有这些都暴露了简单的HTTP端点,用于根据特定的lat / lng组合检索地址。

You can also download the geonames database and use PostGIS or MySQL's spatial extension to build your own service. 您还可以下载geonames数据库并使用PostGIS或MySQL的空间扩展来构建自己的服务。 Advantage is that you won't have to worry about rate limits. 优点是您不必担心速率限制。 Disadvantage is that it won't be very accurate. 缺点是它不会很准确。

SimpleGeo does not have any rate limits but the database is limited to the US the last time I checked. SimpleGeo没有任何速率限制,但我上次检查时数据库仅限于美国。

Assuming you are getting lat/long coordinates, then you could use something like SimpleGeo's services: http://simplegeo.com/ 假设您获得了lat / long坐标,那么您可以使用SimpleGeo的服务: http ://simplegeo.com/

I think the Google option is better, SimpleGeo sounds like way more than you need. 我认为谷歌选项更好,SimpleGeo听起来比你需要的更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM