March 19, 2009

Latitude-Longitude Finder Tool

This easy-to-use, online, browser-based tool will help you find the Latitude/Longitude coordinates of any place on the world map. If you are a coder or a developer interested in using Google Maps API, you will find useful information further below.

How to Use

To find a place on the map, enter its name or address in the text box below. Pan the map around the desired place, zoom in for greater accuracy. Drag the marker over the desired place. The latitude/longitude coordinates of the point below the marker are displayed below the map.

Notes for Coders/Developers

The map is powered by Google Maps. The code is derived from the Google Maps API Examples.

The code consists of/demonstrates the following:

  1. google.maps.Map object
  2. Drag-able google.maps.Marker
  3. A very basic google.maps.Geocoder example
  4. Event listening using google.maps.event.addListener

The event handling is the tricky part. Here is how it works:

  • map.idle event handler re-positions the marker to the center of map. This event is fired when the map becomes idle after panning or zooming.
    • The latitude/longitude display is refreshed inside the event handler.
  • marker.dragend event handler aligns the map with the marker. This event is fired when the user stops dragging the marker.
    • Re-positioning the map fires the map.idle event