var iconRed = new GIcon(); iconRed.image = 'http://www.google.com/mapfiles/marker.png'; iconRed.shadow = 'http://www.google.com/mapfiles/shadow50.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); var center = new GLatLng(35.937496, 14.375416); map.setCenter(center, 10); map.setUIToDefault(); // Set up our GMarkerOptions object markerOptions = { icon:iconRed, draggable: true }; var isAdded = false; GEvent.addListener(map, "click", function(overlay, latlng) { if (isAdded == false){ var marker = new GMarker(latlng, markerOptions); GEvent.addListener(marker, "dragstart", function() { map.closeInfoWindow(); }); GEvent.addListener(marker, "dragend", function() { var point = marker.getLatLng(); //Save coordinates $("#coord").val(point); }); $("#coord").val(latlng); isAdded = true; map.addOverlay(marker); } }); } } $(document).ready(function() { $("#frmMain").validate(); initialize(); });