[OpenLayers-Users] SelectFeature on multiple layers with different events (click + hover)

Fabien Renaud fabienrenaud.fr at gmail.com
Wed Oct 19 07:21:23 EDT 2011


Hi,

Let's say I have two overlays:
 - one made of markers for which I want to handle a click event
 - one other made of curves for which I just want to a handle a hover event
How can I use the SelectFeature to make these two events working well?
Apparently OL doesn't support multiple addControl(<SelectFeature>) and only
handle the last one passed through the addControl method.

In addition, I am using a DragFeature to move some other markers (on a third
overlay) and I loose that control too when enabling the SelectFeature
control on another layer.

I know how to handle one layer with the SelectFeature:
---
/* for each layer */
layer.events.on({
  featureselected: function(e) { onHover(e.feature); },
  featureunselected: function(e) { onBlur(e.feature); }
});
/* and then */
var hover = new OpenLayers.Control.SelectFeature(
  <1 layer or an array of>, {
  clickout: false, toggle: false,
  multiple: false, hover: true,
  box: false
});
map.addControl(hover);
hover.activate();
----

Any idea?

-- 
Fabien Renaud
Georgia Tech Student in Computer Science
ENSEEIHT Student in Computer Science and Applied Mathematics
Phone: 0033 678-363-272
Email: contact at fabienrenaud.com
Web: http://www.fabienrenaud.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111019/60109539/attachment.html


More information about the Users mailing list