尝试获取 mouseUp 事件发生点的坐标时遇到问题。这是一个事件处理程序:
$('#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)));
}
});
我得到了Uncaught TypeError: Cannot read property 'lat' of null 那么,我怎样才能获得注册 mouseUp 事件的点的纬度和经度?