Geoff Posted August 11, 2010 Posted August 11, 2010 I want to embed a Google map on a web page and show results based on a postcode and a distance from said postcode. Any ideas?
tom_newton Posted August 11, 2010 Posted August 11, 2010 You may find a service to do this. DIY is harder. Roughly the steps are: * find a georeferencer - pref one that gives postcode->national grid NOT lat long. This is hard-ish, as the data costs money, though there are free datasets out there, they have a range of issues (dubious provenance, out of date, low accuracy) which may or may not bother you. Last I looked Google did not provide a postcode georeferencing service. * Georeference your "nearest" locations. Store x,y * when you get a query, georeference the postcode, and then compare pythagorean distance to all the others, and sort them (can be done entirely in SQL). This isnt fast, but for small datasets (<1k), all optimisations are worthless * create KML from the results and pass to google maps I'm *very* rusty with the old map work... been out of it a long time, but still maintain a passing interest. You might find that Google needs lat long in KMl, in which case i'd store both nat grid, and ll in your DB. Nat grid is nice as we are a small country we can grid our maps without losing a lot of accuracy. Grid means "distance" and other fun things are easy to calculate.
Geoff Posted August 11, 2010 Author Posted August 11, 2010 Ok. I get the gist of that. I dislike having to DIY it too. Any services that are likely to do my job for me?
tom_newton Posted August 11, 2010 Posted August 11, 2010 Arr. Looks like you still need to do some georeferencing - though you could do this for very small datasets by firing the postcode at google maps and getting the URL back - but you still need to georeference the "input" postcode (I presume you are doing something like a "storefinder").
Geoff Posted August 11, 2010 Author Posted August 11, 2010 I believe this solves the georeferencing problem? The Google Geocoding API - Google Maps API Web Services - Google Code and yes, it's a storefinder kind of thing.
tom_newton Posted August 11, 2010 Posted August 11, 2010 Cool. Will that georeference a single postcode? I'd cache your results in your db mind.
Geoff Posted August 11, 2010 Author Posted August 11, 2010 Would appear to! Try it yourself (open the file in a program that understands UNIX type text files) http://maps.google.com/maps/api/geocode/json?address=LS12 6QA&sensor=false Don't even need an API key 1
Arthur Posted August 11, 2010 Posted August 11, 2010 There's a really good Google Maps plug-in for jQuery called gMap which should do what you want. See the examples page for info on how to use it. 1
tom_newton Posted August 11, 2010 Posted August 11, 2010 Mint. I might now georeference our customer db for a laugh
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now