Where you headin’, luv?

In previous posts I’ve covered the inherent difficulty of geocoding addresses and postcodes in the UK, specifically in order use the geocodes with Google maps. I learned a lot about the limitations of Google’s various geocoding services. To sum up the situation:

Previously I’d been geocoding large batches of addresses/postcodes, but having got the geocodes in order to plot points on the map, I wanted to add search functionality to the map, so that it would zoom in on a given address/postcode. I wanted it to be accurate for both addresses and postcodes, so using what I’d learned, I wrote a javascript function, geocodeUKAddress, which always returns the best geocode that Google can offer, so your website can be as reliable as a London cabbie (again, I can’t embed it here as javascript has a habit of breaking wordpress, though there must be some way to make it safe – I will research).

You will need to include the following in ther head of your webpage too

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=your_api_key_here" type="text/javascript"></script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>

I can’t take credit for the regular expression that recognises UK postcodes, but apart from that, it’s all my own work, which anyone can feel free to use. Unless you maybe work for Rupert Murdoch.

Related posts:

  1. Anarchy in the UKThis damn economic crisis/swine flu outbreak isn’t quite that bad...
  2. Geocoding in the UKThe art of geocoding addresses in the UK, , is...
  3. What’s up, firebug?In the space of one day (in real-time, not blog-post-spacing...
  4. How to spot an obvious idea when you’ve got one, and I quote: Now, somebody has probably already done...
  5. Better jQuery plugins searchEveryone wants one and, let’s face it, anyone cool already...

Tags: , , , , , , , , , ,

Leave a Reply

Security Code: