我需要Google地图中的可拖动标记 [英] I need draggable markers in google maps
本文介绍了我需要Google地图中的可拖动标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Google地图中使用可拖动的标记.
I need draggable markers in google maps..
所以我更改了代码
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});
我如何找到标记的新位置.
how can i find the new position of marker..
推荐答案
我猜您按照文档中的说明缺少了侦听器.
I guess you are missing listeners as explained in the documentation.
请查看此示例:
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
这篇关于我需要Google地图中的可拖动标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文