Mashed Up Maps

by @edent | # # # | 3 comments | Read ~190 times.

As part of my project to create a mobile polling station locator site, I’ve been playing with various mapping APIs.

As a base experiment, I passed the postcode of a polling station (GU22 7DT) to both Google Maps and Yahoo Maps. Here are the results.

Yahoo! MapsGoogle Maps

Two things of interest to note.

Firstly, Google has a specific “Mobile” call in the API, it reformats the map image to be more readable on the mobile – I think you’ll agree that Google edges out Yahoo here.

Secondly, Google maps is less accurate than Yahoo! Maps. Severely so. While maps.google.com is highly accurate when passed a postcode, the API seems only to look at the first part and discard the rest. Yahoo on the other hand is unnervingly precise.

What to do? Well, as all the cool kids are doing, let’s have ourselves a mashup!

We can call Yahoo Maps to get the Latitude and Longitude of a postcode thusly
http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA--&zip=gu227dt&state=uk
This will return
<Latitude>51.318691</Latitude>
<Longitude>-0.543540</Longitude>
<Address/>
<City>Woking, GU22 7DT</City>
<State>United Kingdom</State>
<Country>GB</Country>
We take the Latitude and Longitude and pass it to Google Maps like so
http://maps.google.com/staticmap?center=$lat,$long&markers=$lat,$long,tiny&zoom=14&size=240x240&maptype=mobile&key=&sensor=false
Which nets us this map.

Google Map from Yahoo Geo Location

Google Map from Yahoo Geo Location

Hey presto! Better looking than the Yahoo Map and better accuracy than the Google Map.

The geocoding prescision of the Google Maps API is very poor for UK postcodes. There really shouldn’t need to be this need sort of work around.

This is the sort of data that the UK government should be providing. The Ordnance Survey have an API but it seems restricted to JavaScript which isn’t very useful for most mobile phones. Nevertheless I’ll have a play with it and see if it’s more useful.

Edit

I am now using Ernest Marples’ Postcode Latitude/Longitude Lookup API which has much greater accuracy than either Google or Yahoo.

3 thoughts on “Mashed Up Maps

  1. knersis says:

    Google were specifically asked to reduce the accuracy of the geocoding api whn fed a postcode on it’s own – and reduced it to district level accuracy – it’s a bit of an anomaly that yahoo actually returns unit level accuracy. This was discussed at opentech – harry metcalfe had an interesting ‘solution’ to the postcode clusterf*ck. I can’t remember the url atm. There are workarounds (like scraping google) – but they’re all a little dubious one way or another.

  2. You might want to check out the Open Street Map data here (crowdsourced maps)

    CloudMade has a Geolocation API that can return a polygon bounding box for a postcode – indeed looking up GU22 7DT returns exactly that.

    Details here http://developers.cloudmade.com/wiki/geocoding-http-api/Find_by_postcode

    So you’d get back

    {“found”: 1, “type”: “FeatureCollection”, “features”: [{“properties”: {“name”: “GU22 7”}, “centroid”: {“type”: “POINT”, “coordinates”: [51.31415, -0.55306]}, “geometry”: {“type”: “POLYGON”, “coordinates”: [[[51.32207, -0.55709], [51.32152, -0.55067], [51.31999, -0.55045], [51.31146, -0.53247], [51.31112, -0.53228], [51.31079, -0.53463], [51.30639, -0.55158], [51.30992, -0.55488], [51.31069, -0.55886], [51.3086, -0.56763], [51.31391, -0.56872], [51.31505, -0.56526], [51.32185, -0.56727], [51.32159, -0.5613], [51.31599, -0.56171], [51.31674, -0.55952], [51.32181, -0.55839], [51.32207, -0.55709]]]}, “type”: “Feature”, “id”: 21676700, “bounds”: [[51.30639, -0.56872], [51.32207, -0.53228]]}], “bounds”: [[51.30639, -0.56872], [51.32207, -0.53228]], “crs”: {“type”: “EPSG”, “properties”: {“code”: 4326, “coordinate_order”: [1, 0]}}}

Leave a Reply

Your email address will not be published. Required fields are marked *