I try to trigger the listener to "Dragend" so I could actually locate
the lat,lng coordinate. But it seems don't work with my code. Below is
the code I'm working with.


 var marker;
    var infowindow;


        var markersArray = [];

    function initialize() {
      var latlng = new google.maps.LatLng(2.233286, 102.272476);
      var options = {
        zoom: 13,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      var map = new
google.maps.Map(document.getElementById("map_canvas"), options);


    google.maps.event.addListener(map, "click", function(event) {
        deleteOverlays();
                  marker = new google.maps.Marker({
          position: event.latLng,
                  title: 'Your House',
          map: map,
                  draggable: true



        });


                markersArray.push(marker);


    });




        google.maps.event.addListener(marker, "dragend", function(event) {

                document.getElementById("lat").innerHTML = latlng.lat();
                document.getElementById("lon").innerHTML = latlng.lng();
          });

    }






    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request.responseText, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }


        function deleteOverlays() {
    if (markersArray) {
      for (i in markersArray) {
        markersArray[i].setMap(null);
      }
      markersArray.length = 0;
    }
  }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
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