The Google Maps API lacks a Geocoder. This extension integrates free geocoders (for non-commercial use) directly into Google Maps.
Click the "Geocode" button in the map above to search for US addresses, or International cities.
How: Adding a geocoder to your Google Map is as simple as the following Javascript.
For version 1..
<script src="mgeocoder.js"></script>
<script>
map = new GMap(document.getElementById("map"));
geocoder = new MGeocoder();
map.addMGeocoder(geocoder);
</script>
..and version 2..
<script src="mgeocoder.2.js"></script>
<script>
map = new GMap2(document.getElementById("map"));
map.addControl(new MGeocoder());
</script>
Download: A proxy is required to work around browser security. A simple proxy in php is available
here. Rename to proxy.php and place in the same directory as your GMap application. The javascript
GMaps v1, and
GMaps v2.
License: Use of the MGeocoder class requires compliance with Terms of Use of
geocoder.us and
brainoff.com/geocoder. Check with these services before deploying MGeocoder!
Contact: I am reachable at [mikel_maron yahoo com]. My
weblog.
Todos (help welcome!):
- Make the button look better. Maybe subclass GMapTypeControl
- Option to add marker when location is navigated to.
- Generally more control over what happens when location is found. Callback mechanism.
- better error messages
- allow MGeocoder to be called from form external to map