[OpenLayers-Users] Can multiple mouse handler controls be active?

Jean-François Gigand jf at geonef.fr
Tue Aug 23 09:27:22 EDT 2011


>From experience, it is "physically" not possible to get events on
different vector layers.
The control feature makes a trick: it moves the root elements of each
vector layer to a common layer (RootContainer), which allow features
from the different layers to be hovered/selectable, etc.

I see what kind of specific behaviour you want. If I were you, I would
write my own select control extending OL's Control.SelectFeature, or
directly extending Control.
Control.SelectFeature is a good example then.

Use Layer.Vector.RootContainer and manage the handlers yourself!

Good luck,

Jean-François Gigand - Geonef
Paris, France - http://geonef.fr/




2011/8/23 Rohan Parkes <melanchthon76 at gmail.com>:
> The problem is that I need different behaviour on each layer. I need the
> lower layer to have exclusive selectivity, but the upper layer to be
> arbitrarily clickable. I think if I made both layers selectable via the same
> control, I would have to enable multiple selectivity, which would lose the
> exclusivity.  I would also have to intercept the select event to decide
> whether to invoke the click behaviour or the select behaviour, which would
> mean I would then have to invoke the select functionality programmatically.
> Additionally, selecting a feature on the lower layer triggers AJAX callbacks
> to populate the upper layers, but this doesn't happen when you click the
> upper layers. It seemed simpler to just have two controls with the behaviour
> I need hard-wired.
>
> I can see why it might not be advisable (and perhaps therefore not possible)
> to have two mouse handlers active - when you click a feature on the top
> layer, the click might still propagate to the lower layer, potentially
> re-selecting the already-selected feature. However, it would still be easier
> to manage. What I would want is for the mouse event not to propagate if it
> clicks on a feature on the upper layer.
>
> Rohan Parkes.
>
> On Mon, Aug 22, 2011 at 9:47 AM, Jean-François Gigand <jf at geonef.fr> wrote:
>>
>> Hi Rohan,
>>
>> If you want multiple vector layers to be selectable, you just have to
>> pass them as an array to the select control, instead of creating one
>> select control for each layer.
>>
>> Hope this helps,
>>
>> Jean-François Gigand - Geonef
>> Paris, France - http://geonef.fr/
>>
>>
>>
>>
>> 2011/8/22 Rohan Parkes <melanchthon76 at gmail.com>:
>> > I have a vector layer displaying geometries, with a selectFeature
>> > control.
>> > When the user selects a feature, one or more vector layers become active
>> > on
>> > top of the lowest layer, displaying geometries that abut the selected
>> > geometry. Additionally, there is a top layer with icons that displays a
>> > popup containing infomation about the abutting geometry when clicked.
>> >
>> > The icon layer is implemented as a vector layer rather than as a marker
>> > layer. (The documentation seems to indicate that the marker layer type
>> > is
>> > deprecated. There were additional reasone why this wasn't the favoured
>> > solution.) To make the icons clickable, I have added a customised click
>> > control to that layer, inspired by an example in the OL demos.
>> >
>> > The problem is that when active, the click control seems to be
>> > preventing
>> > the clicks from permeating to the featureSelect control, so that when
>> > the
>> > top icon layer displays, the user can no longer select a geometry on the
>> > lowest layer. This is not a problem in IE, but is in every other
>> > browser.
>> >
>> > The Feature handler in the click control has parameters called stopClick
>> > and
>> > stopDown that seem to be designed to allow mouse events to permeate, but
>> > setting them to true has no effect (and in any case, as they default to
>> > false, they should be causing the same problem in IE).
>> >
>> > Is it possible to have multiple controls active that respond to mouse
>> > events? Otherwise, can anyone suggest a better implementation for what I
>> > am
>> > trying to build?
>> >
>> > Rohan Parkes
>> > Melbourne
>> > Australia
>> >
>> > _______________________________________________
>> > Users mailing list
>> > Users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/openlayers-users
>> >
>> >
>
>


More information about the Users mailing list