0

我对 Openlayers 事件有疑问:

我想为标记层注册拖动事件,还为路线层注册悬停事件。但似乎地图只对 z-index 最高的图层上的事件做出反应。是否有解决方案让两个不同的事件监听器可以同时工作?

以下是相关代码:

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();
4

1 回答 1

0

如果您使用SelectFeature控件来处理悬停在路线上,请尝试将stopDown属性设置false为允许将mousedown事件传播到底层,如示例

var selector = new OpenLayers.Control.SelectFeature(routeLayer, {
    hover: true,
    autoActivate: true
});
selector.handlers.feature.stopDown = false;

我正在使用此代码功能内单击时拖动整个地图(否则拖动不起作用)。

在OpenLayers.Handler.Feature.stopDown和其他相应属性中查看更多信息。

你也可以从这段代码中得到一些线索(我自己没有尝试过,但乍一看它似乎很有用;): http: //lists.osgeo.org/pipermail/openlayers-users/2010-May/017688.html

于 2013-10-22T22:51:27.463 回答