Whilst this may be common knowledge, I only recently discovered how “hackable” the Google Maps implementation is in regards to using latitudes and longitudes. While I was reading the Add Google Maps’ Directions to Your Site post from the Malevolent Design weblog, I thought it would be nice to have the ability to direct people to a particular spot that cannot be referenced by name in Google Maps. As it turns out, this is quite simple.
To get the latitude and longitude of a particular spot, navigate to it in Google Maps (ie. search for the nearest reference point that Google Maps recognizes, and then navigate to the particular area you would like to reference). Make sure the map is zoomed in and centred on the spot you would like to reference, and then click on the “Link to this page” link (currently on the upper right hand side of the screen). Google Maps will respond by changing the URL to a bookmarkable URL that includes the latitude and longitude in it, such as:
http://maps.google.ca/maps?q=greenall+school&ll=50.487160,-104.266577&spn=0.004059,0.005240&hl=en
The latitude and longitude are the two numbers after the &ll= section of the URL, in this case 50.487160 and -104.266577. You can use this information to now create a form that generates custom directions to the site you have referenced.
For example, enter your starting location (as a ZIP/Postal Code/City/Address or any other form Google Maps recognizes) to obtain custom directions to Greenall School in Balgonie (where I will be teaching this fall):
The code is simple, and easily adaptable to any location:
<p><label for=“saddr”>Your ZIP code</label>
<input type=“text” name=“saddr” id=“saddr” value=“” />
<input type=“submit” value=“Go” />
<input type=“hidden” name=“daddr” value=“[destination]“ />
<input type=“hidden” name=“hl” value=“en” /></p>
</form>
All you have to do is replace the [destination] part above with the comma separated lat and long values, in this case: 50.487160,-104.266577