Dave's Brain

Browse - programming tips - google map geocode for one address and marker for something else

Date: 2010mar3
Language: javaScript

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');
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, 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.