Where magic lives

Tuesday, January 02, 2007

Converting between Latitude/Longitude & OS National Grid Reference points in PHP (another fun postcode map)

I decided to have a play around with the Google Maps Javascript API. Seeing as I recently acquired the UK postcode database I thought I'd plot postcodes onto Google Maps.

The tricky part turned out to be converting between the grid references used in the PAF and latitude and longitude. Fortunately I found a page explaining how to do the conversion in Javascript. I needed the conversion to be done server side so I have ported the code to PHP [source].

To play with my map go to this page. To stop people screen scraping my postcode database the script will stop working after you have moved the map more than 200 times.

Labels: ,


  • Hi David,
    Interesting article! Seeing as you have already covered this ground is there any chance you can let me know how it is best to aquire this postcode database? Is it just through the Royal mail - or are there alternative cheaper versions?



    By Blogger jimmyc, At 8:54 pm  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home