1
嘗試獲取mouseUp事件發生點的座標時遇到問題。 這裏是事件處理程序:將元素拖動到地圖後,無法從mouseUp事件中獲取lon-lat(開放層)
$('#someDiv')
.on("mouseup", map, function(event) {
click.trigger(event, map, d[i]);
})
這裏是一個觸發器:
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
initialize: function(options) {
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
this, arguments
);
this.handler = new OpenLayers.Handler.Click(
this, {
'mouseup': this.trigger
}, this.handlerOptions
);
},
trigger: function(e, map, k) {
var marker = map.getLonLatFromPixel(e.xy);
var point = new OpenLayers.Geometry.Point(new OpenLayers.LonLat(marker.lat.toFixed(5),
marker.lng.toFixed(5)));
}
});
我遺漏的類型錯誤:無效的不能讀取屬性「緯度」 所以,我怎樣才能得到LAT和lon的點,在哪裏mouseUp事件被註冊?
ty bro!accepted。 – Arti88