19 Apr 2007

bookmarklet to find latitude longitude in google maps


i searched high and low for a simple google maps bookmarklet which would easily output the latitude and longitude of the center of the map. i couldn't find anything that works on the recent version of google maps. so i spent some time inspecting the javascript and here it is:

javascript:alert(window.gApplication.getMap().getCenter())
bookmarklet: get center from google maps.

it actually looks suprisingly easy when i finally inspected all the objects in the global scope (window), but it took me ages to figure out how to use the firefox javascript debugger, and then spent ages hitting brick walls be searching through the code for references to where it kept the GMaps2 object. but in fact, it was there all along in the index.html file as gApplication.


You can reply to me about this on Twitter: