【发布时间】:2014-11-14 09:49:56
【问题描述】:
我将 Openlayers 3 用于我的地图应用程序。我需要确定用户移动了地图。经过一段时间的谷歌搜索后,我发现地图对象应该触发“拖动”和“拖动”事件。不幸的是,这不会发生在我身上。我只触发了 moveend 事件,但它会在地图移动时触发 - 编程或用户操作。拜托,你能帮我解决这个问题吗?我的代码是:
function _mappingAPI()
{
this.map = new ol.Map({
target: 'map_cont',
controls: controls,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: this.view
});
this.map.on('moveend', function(evt){
writeConsoleLog("DEBUG move end",3);
});
this.map.on('dragend', function(evt){
writeConsoleLog("DEBUG drag end",3);
});
this.map.on('drag', function(evt){
writeConsoleLog("DEBUG drag",3);
});
}
【问题讨论】:
-
目前没有此类事件。随意为此创建 GitHub 问题。
-
pointerdrag事件可能是您所追求的。然而,当地图不能被拖得更远时,它也会被触发,例如因为你处于它范围的边缘。请注意,drag和dragend事件是 OpenLayers 2,而不是 3。 -
是的,pointerdrag 对我有用——我刚刚在帮助页面上发现了取消选中“稳定版本”的“奇迹”......;)。非常感谢。
标签: drag-and-drop drag openlayers-3