我需要谷歌地图中的可拖动标记..
所以我改了代码
var point = new GLatLng(app.entries [id] .data.lat,app.entries [id] .data.lng);
var m = new GMarker(point,app.icon [app.entries [id] .data.icon]);
到
var point = new GLatLng(app.entries [id] .data.lat,app.entries [id] .data.lng);
var m = new GMarker(point,{draggable:true});
我怎样才能找到标记的新位置..
答案 0 :(得分:1)
我猜你正如文档中所解释的那样缺少听众。
请看一下这个样本:
var map = new GMap2(document.getElementById("map_canvas"));
var center = new GLatLng(37.4419, -122.1419);
map.setCenter(center, 13);
var marker = new GMarker(center, {draggable: true});
GEvent.addListener(marker, "dragstart", function() {
map.closeInfoWindow();
});
GEvent.addListener(marker, "dragend", function() {
marker.openInfoWindowHtml("Just bouncing along...");
});
// to get the point of dragger.
GEvent.addListener(markerD2, "drag", function(){
document.getElementById("location").value=marker.getPoint().toUrlValue();
});
map.addOverlay(marker);
在这里工作得很好 - http://code.google.com/apis/maps/documentation/javascript/v2/overlays.html#Draggable_Markers