Get latitude/longitude of Google map

by Blake Schwendiman on April 10, 2009

I do a fair amount of work where I need to quickly get the latitude and longitude of a given address. Most of the time I just head over to maps.google.com and type in the address, then use the link button and copy/paste just the latitude and longitude. I find this method to be workable in most cases, but I found a little Javascript snippet that works well to display exactly what I need in a prompt.

menuThe Javascript method works well, but it’s a little inconvenient when I’m copying and pasting several addresses, the JS code and the resulting geolocations in one session. Today I was doing this again and it struck me how convenient it would be to have a browser button that would do what the Javascript does. So I set that up.

In Firefox, I simply added a custom bookmark to my Bookmarks toolbar (View, Toolbars, Bookmark Toolbars). To do this, assuming the Bookmark toolbar is visible, right click (or control click for Mac users) on it and select New Bookmark. In the properties box, enter this Javascript into the location field:

[-]?View Code JAVASCRIPT
javascript:void(prompt('',gApplication.getMap().getCenter()));

propertiesNow you have a button that will display the latitude and longitude of the current map (on the Google maps site) in a convenient Javascript prompt box. Like I said, this isn’t going to change your life, but it might save you a few cycles … and that’s worth something.

Comments:

Comments on this entry are closed.