Thursday, July 2nd, 2009

GeoMaker – geo locations as microformats or a map from texts or URLs

Category: JavaScript, JSON, Yahoo!

<p>As preparation for an upcoming tech talk about Placemaker I thought it would be good to take a bit of the pain out of the geolocation service by making an interface for it. Placemaker works the following way: you post some content or a URL to it, it goes through the content or gets the content from the URL and analyzes it. It then finds geographical locations in the text and disambiguates them (for example to skip names like “Jack London” and not consider it the city London). Finally you get it back as XML.

The annoying thing is that Placemaker only support POST request and does not have a JSON output – for now. GeoMaker allows non-developers to enter some text or a URL, filter the results (using YUI datatable) to remove false positives (no system is perfect) and get the embed code for a Yahoo Map or a list of microformatted locations as copy+paste. See the screencast to get the end user experience:

Of course, every time you build something like that, red-blooded developers will ask for an API to do the same thing (and pointing them to Placemaker wasn’t enough). So here it is:

http://icant.co.uk/geomaker/api.php takes two parameters: url of the web document to load and output which could be map, kml, microformats, csv, or json (with callback for JSON-P). Using this you can analyze a url in JavaScript and get the data back as an array:

  1. <script>function geomaker(o){
  2.   for(var i=0,j=o.length;i<j ;i++){
  3.    // o[i] will have lat, lon, title and match
  4.  }
  5. }</script>
  6. <script src="http://icant.co.uk/geomaker/api.php?url=http://ajaxian.com&output=json&callback=geomaker"></script>

The Ajaxian.com output right now would be:

javascript
< view plain text >
  1. geomaker(
  2.   [
  3.     {"lat":"42.3586","lon":"-71.0567",
  4.      "title":"Boston, MA, US","match":"Boston"},
  5.     {"lat":"42.3586","lon":"-71.0567",
  6.      "title":"Boston, MA, US","match":"Boston, MA"},
  7.     {"lat":"40.7075","lon":"-106.918","title":"Clark, CO, US",
  8.      "match":"Clark, Co"},
  9.     {"lat":"42.3115","lon":"43.3658","title":"Georgia",
  10.      "match":"Geo"},
  11.     {"lat":"44.9601","lon":"7.16229",
  12.      "title":"Rey, Piedmont, IT","match":"Rey"}
  13.   ])

Related Content:

2 Comments »

Comments feed TrackBack URI

Sometimes the length of the representation of geo locations also matters e.g. in Twitter messages. Therefore I would like to represent a solution for this:

The service Twittori uses a modified Geohash algorithm (see Wikipedia for details) to create very short URL which just consume 6 characters to represent a geo location. Here is an example: http://GE0.at/0GGmJW.

This could be an alternative for other services too, to not need to use the TinyURL services for geo location purposes in Twitter.

Comment by perenzo — July 2, 2009

Freaky timing – just the other day I was just talking about how useful a service like this would be to Ubiquity. Anyway, looks very promising!

Comment by Unfocused — July 2, 2009

Leave a comment

You must be logged in to post a comment.