最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Alternative to Google Maps Geolocation API - Stack Overflow

programmeradmin10浏览0评论

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?

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?

Share Improve this question edited Jul 9, 2012 at 16:21 Ryan Brodie asked Jul 9, 2012 at 16:16 Ryan BrodieRyan Brodie 6,6208 gold badges42 silver badges58 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 7

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.

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/

Example YQL query:

http://query.yahooapis.com/v1/public/yql?q=SELECT * FROM geo.places WHERE text="Seattle" and placeTypeName = "Town"

Response 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 -->

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.

Then there's also Yahoo's geolocation API which has higher limits than Google's.

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 service you 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 hosts a web service with no limits.

发布评论

评论列表(0)

  1. 暂无评论