[OSM-talk] Name finder: Where Am I?
David Earl
david at frankieandshadow.com
Tue Aug 14 20:53:26 BST 2007
Have you ever been zoomed right in to the map and not sure where you
are? Now name finder can tell you.
Just click on the "Where Am I" button in the name finder at
http://www.frankieandshadow.com/osm/
and it shows you the location of the centre of the map in context.
As well as the familiar sentence at the top, the main thing is the
contextual map "target" on the left. It shows up to six nearby places.
The challenge of doing this is two-fold:
Firstly choosing which places out of the sometimes hundreds of
possibilities. There's a weighting system which scores places according
to their status (city high, hamlet low), how far away they are, and
especially whether they are the closest place of increasing importance
(so you'll always get the nearest place, whatever it is, but you are
unlikely to get hamlets further away than towns unless there is nothing
else to show.
Secondly, positioning the text on the mini-map so it doesn't all clash
in a horrible mess or go outside the target. At the moment, it adjusts
the text, but doesn't take account of the blob that represents the
place. I could do that too, but at the expense of distributing the text
further away from its location.
It's all written as Ajax Javascript (calling on the namefnder for the
place details, so it would be easy to incorporate elsewhere).
POSTCODES
Experimentally, the current version now recognises UK postcodes and
tries to look them up. It does this without using a geolocator database
- it goes to Google to search for the postcode and then tries to extract
an address from the results, which it then sends to the name finder as
if you had typed it.
It's surprising quite how many postcodes get a hit this way, but of
course not all do. I need to do some further work on the address pattern
matching especially for addresses that don't have numbers in them - you
may get some peculiar "not found" messages because of this. Of course,
the street or whatever it determines has to then be on the map to be
located by name finder,but if it isn't you'll at least see the address I
thought I was looking for.
SOURCE CODE
I have also now checked in the source code, mainly for safety's sake,
into the Sites directory of svn, after some tidying up and updating
comments etc. So if you want to see how it works, it is all there now to
see.
Enjoy,
David
More information about the talk
mailing list