function createMarker(point,text,color) { // Create a base icon for all of our markers that specifies the // shadow, icon dimensions, etc. var baseIcon = new GIcon();baseIcon.shadow="http://www.google.com/mapfiles/shadow50.png";baseIcon.iconSize = new GSize(20, 34); baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); baseIcon.infoShadowAnchor = new GPoint(18, 25); var icon = new GIcon(baseIcon); if(color == "GREEN") icon.image = "http://www.yoursite.com/markerGreen.png"; else icon.image = "http://www.yoursite.com/marker.png"; var marker = new GMarker(point, icon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(text); }); return marker; } function loadmap() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(lat, lon), 13); var point = new GLatLng(lat,lon); map.addOverlay(createMarker(point, "Your Text Here","DEFAULT")); var point = new GLatLng(lat,lon); map.addOverlay(createMarker(point, "Your Text Here","GREEN")); } }
Posted: Thursday, January 25, 2007 11:27 AM by Google Fact with 1 comment(s)