// JavaScript Document for Google MAP API var map; var geocoder; function initialize() { var myLatlng = new google.maps.LatLng(15, 150); var myOptions = { zoom: 1, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas_1"), myOptions); geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'address': '1C Molesworth Street, Kew, 3101, Victoria, Australia' }, addAddressToMap); } var markersArray = []; function addAddressToMap(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); clearOverlays(); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location, }); var infowindow = new google.maps.InfoWindow({ content: "
1C Molesworth Street, Kew, 3101, Victoria, Australia

" }); infowindow.open(map, marker); markersArray.push(marker); map.setZoom(15); var addr = document.getElementById('address'); addr.firstChild.data = results[0].formatted_address; } else { alert("Geocode was not successful for the following reason: " + status); } } // Removes the overlays from the map, but keeps them in the array function clearOverlays() { if (markersArray) { for (i in markersArray) { markersArray[i].setMap(null); } } }