Dave's Brain

Browse - Programming Tips - With Google Maps, how can I geo-search for one address and mark it

Date: 2010mar3
Language: javaScript
Keywords: geocode

Q.  With Google Maps, how can I geo-search for one address and mark it
with something else?

A.  Here you go:

map = new GMap2(document.getElementById('map_canvas')); geocoder = new GClientGeocoder(); function showAddress(geoaddress, displayaddress) { // Error checking removed geocoder.getLatLng( geoaddress, function(point) { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(displayaddress); } ); } function exampleUse() { showAddress('123 Main St, My Town', 'My House'); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.