开发者

To get the position of draggable markers

I am using draggable markers in google maps. I have to get the position of markers after dragging becau开发者_C百科se i have to store the new position of marker

The code is

   var m = new GMarker(point,{draggable: true});
   m.entry_id = id;
   m.isMarker = true;
   app.entries[id].marker = m;


Here is my example that will display the new location of the marker in and info-window at the new location after the marker has been dragged:

//assuming u have lat and long as latitude and longitude of the initial position
var location = new GLatLng(lat,long);   

var marker = new GMarker(location, {draggable: true});

GEvent.addListener(marker, "dragstart", function() {
  map.closeInfoWindow();
  });

GEvent.addListener(marker, "dragend", function() {
    var latlng = marker.getLatLng();
    marker.openInfoWindowHtml("New Lat : " + latlng.lat() + ", New Long : " + atlng.lng() );
  });

Am assuming you are using API version 2, the solution is a bit different for Version 3, but just a matter of change in the calling conventions sort of.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜