javascript Google Maps Geolocation API 的替代方案
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11399069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Alternative to Google Maps Geolocation API
提问by Ryan Brodie
I'm working on a project that involves a huge volume of real time data per second (achieved by websockets). Because of this, it can't handle calling Google's API to convert a City + Region to a longlat coordinate. I'm getting about a 1 to 100 success rate. Is there an unlimited alternative to City & Region to Coordinate service of the Google API? Ideally a locally stored JSON array of such data?
我正在处理一个每秒涉及大量实时数据的项目(由 websockets 实现)。因此,它无法处理调用 Google 的 API 将 City + Region 转换为 longlat 坐标。我的成功率大约是 1 到 100。Google API 的城市和地区协调服务是否有无限的替代方案?理想情况下,本地存储的此类数据的 JSON 数组?
采纳答案by josh3736
Usually when you're dealing with a large number of data points, you'd geocode them once on the server. Then you can stream the lat/longs to your clients ready to use.
通常,当您处理大量数据点时,您会在服务器上对它们进行一次地理编码。然后,您可以将经纬度流式传输到准备使用的客户端。
Google has a Geocoding web serviceyou can use from your server, but there's a request limit of 2,500/day. If that won't work, you can also look in to OSM's Nominatim; Mapquest hostsa web service with no limits.
Google 有一个地理编码网络服务,您可以从您的服务器使用,但请求限制为 2,500/天。如果这不起作用,您还可以查看OSM的 Nominatim;Mapquest托管无限制的 Web 服务。
回答by JG in SD
You can use a service provided by Yahoo called YQL. This service is free for a limited number of requests, up to 100,000 per day. Then you can retrieve the latitude and longitude out of the response XML at query/results/place/centroid
.
您可以使用 Yahoo 提供的名为 YQL 的服务。此服务对有限数量的请求免费,每天最多 100,000 个。然后您可以从响应 XML 中检索纬度和经度query/results/place/centroid
。
One thing I've noticed with this service is the city names need to be exact, and it is possible for there to be multiple results.
我注意到这项服务的一件事是城市名称需要准确,并且可能有多个结果。
http://developer.yahoo.com/yql/
http://developer.yahoo.com/yql/
Example YQL query:
YQL 查询示例:
http://query.yahooapis.com/v1/public/yql?q=SELECT * FROM geo.places WHERE text="Seattle" and placeTypeName = "Town"
http://query.yahooapis.com/v1/public/yql?q=SELECT * FROM geo.places WHERE text="Seattle" and placeTypeName = "Town"
Response XML:
响应 XML:
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2012-07-09T16:20:40Z" yahoo:lang="en-US">
<results>
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/2490383">
<woeid>2490383</woeid>
<placeTypeName code="7">Town</placeTypeName>
<name>Seattle</name>
<country code="US" type="Country">United States</country>
<admin1 code="US-WA" type="State">Washington</admin1>
<admin2 code="" type="County">King</admin2>
<admin3/>
<locality1 type="Town">Seattle</locality1>
<locality2/>
<postal/>
<centroid>
<latitude>47.603561</latitude>
<longitude>-122.329437</longitude>
</centroid>
<boundingBox>
<southWest>
<latitude>47.422359</latitude>
<longitude>-122.472153</longitude>
</southWest>
<northEast>
<latitude>47.745071</latitude>
<longitude>-122.176193</longitude>
</northEast>
</boundingBox>
<areaRank>6</areaRank>
<popRank>12</popRank>
</place>
</results>
</query>
<!-- total: 82 -->
<!-- engine5.yql.mud.yahoo.com -->
回答by ErJab
Have a look at datasciencetoolkit.org. They offer a VM image/AMI that you can host on EC2 and make geolocation calls to your own server and hence no API limits.
看看 datasciencetoolkit.org。他们提供了一个 VM 映像/AMI,您可以将其托管在 EC2 上并对您自己的服务器进行地理定位调用,因此没有 API 限制。
Then there's also Yahoo's geolocation API which has higher limits than Google's.
然后还有雅虎的地理定位 API,它比谷歌的限制更高。