Sorry i have posted the wrong code above.

Should be

//Useful links:
// 
http://code.google.com/apis/maps/documentation/javascript/reference.html#Marker
// 
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
// http://jqueryui.com/demos/autocomplete/#remote-with-cache
      
var geocoder;
var map;
var marker;
    
function initialize(){
//MAP
  var latlng = new google.maps.LatLng(41.659,-4.714);
  var options = {
    zoom: 16,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.SATELLITE
  };
        
  map = new google.maps.Map(document.getElementById("map_canvas"), options);

       
  //GEOCODER
  geocoder = new google.maps.Geocoder();
        
  myMarker = new google.maps.Marker({
    map: map,
    draggable: true
  });
                
}
        
$(document).ready(function() { 
         
  initialize();

      var address = document.getElementById("address").value;

    geocoder.geocode( { 'address': address}, function(results, status) {

      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var myMarker = new google.maps.Marker({
            map: map,
            draggable: true,
            position: results[0].geometry.location,
        });





    map.setZoom(18);
    
    /* When geocoding "fails", see if it was because of over quota error: */
            } else if (status == 
google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
              wait = true;
              setTimeout("wait = false", 1000);

            } else {
              alert("Geocode was not successful for the following reason: " 
+ status);
            }
    });


google.maps.event.addListener(myMarker, 'dragend', function(evt){
    document.getElementById('current').innerHTML = '<p>Marker dropped: 
Current Lat: ' + evt.latLng.lat().toFixed(3) + ' Current Lng: ' + 
evt.latLng.lng().toFixed(3) + '</p>';
});

google.maps.event.addListener(myMarker, 'dragstart', function(evt){
    document.getElementById('current').innerHTML = '<p>Currently dragging 
marker...</p>';
});

  
});

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-maps-js-api-v3/-/rYXtLoEJhScJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to