var obj_google_map; var obj_google_geo; function googlemap_init() { var zoom_data = parseInt(document.getElementById("gmap_zoom").value, 10) - 3; var latlng = new google.maps.LatLng(41, 133); var opts = { zoom: zoom_data, mapTypeId: google.maps.MapTypeId.ROADMAP, center: latlng, scrollwheel: false }; obj_google_map = new google.maps.Map(document.getElementById("google_map"), opts); obj_google_geo = new google.maps.Geocoder(); var req = { address: decodeURIComponent(document.getElementById("gmap_address").value) , }; obj_google_geo.geocode(req, gMapResultCallback); } function gMapResultCallback(result, status) { if (status != google.maps.GeocoderStatus.OK) { alert(status); return; } if(document.getElementById("gmap_lat").value == "" && document.getElementById("gmap_lon").value == ""){ var latlng = result[0].geometry.location; } else{ var latlng = new google.maps.LatLng(document.getElementById("gmap_lat").value,document.getElementById("gmap_lon").value); } obj_google_map.setCenter(latlng); var marker = new google.maps.Marker({position:latlng, map:obj_google_map, title:latlng.toString(), draggable:false, zoomControl:true}); google.maps.event.addListener(marker, 'dragend', function(event){ marker.setTitle(event.latLng.toString()); }); }