我对 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();