Events 使用Openlayers在多个层上注册不同的事件
我对Openlayers事件有问题: 我想注册标记层的拖动事件,以及管线层的悬停事件。但地图似乎只对z指数最高的图层上的事件作出反应。是否有一种解决方案,使两个不同的事件侦听器可以同时工作 以下是相关代码:Events 使用Openlayers在多个层上注册不同的事件,events,openlayers,Events,Openlayers,我对Openlayers事件有问题: 我想注册标记层的拖动事件,以及管线层的悬停事件。但地图似乎只对z指数最高的图层上的事件作出反应。是否有一种解决方案,使两个不同的事件侦听器可以同时工作 以下是相关代码: this.theMap = new OpenLayers.Map("map", options); this.theMap.addLayer(waypointsLayer,routeSegmentLayer); var dragControl = new OpenLayers.Control
this.theMap = new OpenLayers.Map("map", options);
this.theMap.addLayer(waypointsLayer,routeSegmentLayer);
var dragControl = new OpenLayers.Control.DragFeature(waypointsLayer, {
'onComplete': function(feature, pixel){
self.emit('map:markerAdded', feature);
}
});
this.theMap.addControl(dragControl);
dragControl.activate();
var selectRouteSegment = new OpenLayers.Control.SelectFeature(
routeSegmentLayer,
{
multiple: true,
hover: true,
onSelect: f_select,
onUnselect: f_unselect
});
this.theMap.addControl(selectRouteSegment);
selectRouteSegment.activate();
如果您使用
SelectFeature
控件来处理悬停在路由上的操作,请尝试将stoppdown
属性设置为false
以允许将mousedown
事件传播到底层,如示例所示
var选择器=新建OpenLayers.Control.SelectFeature(routeLayer{
哈弗:没错,
自动激活:真
});
selector.handlers.feature.stoppdown=false;
我使用这段代码在功能中单击时拖动整个地图(否则拖动不起作用)
有关详细信息,请参见和其他相应属性
此外,您还可以从该代码中获得一些线索(我自己没有尝试过,但乍一看它似乎很有用;):
将函数绑定到事件时,源代码看起来是什么样子?OpenLayers绝对能够实现您所描述的任何功能。您好,我刚刚添加了代码。感谢您的提示,我已经尝试过了,但它在我的情况下不起作用,将来可能会有用。