[OpenLayers-Dev] Vector layer - Hover and click at same time

Eric Lemoine eric.c2c at gmail.com
Tue Jul 8 17:00:58 EDT 2008


Hi. The select feature control's primary goal is select features, i.e.
change feature style to the select render intent. So if you use two
select feature controls on the same layer, one with hover and one
without, when moving over the feature the hover control will select it
and on click the click control wont do anything because it'll figure
it's already selected. What you probably want is create your own
feature handler-based control. That control's purpose would be to
execute a uses-defined func when a click or hover occurs on a feature.
I even think that such a control should go in OpenLayers and that the
select feature control should be based on it. Patches very welcome :)
Eric

2008/7/8, Ivan Grcic <ivan.grcic at geofoto.hr>:
> Dear list,
>
> I have one question about vector layer that I add on my map.
> Everything works perfect, but i want to add some functionality and I
> dont know if its possble to do it, because Im just getting deeper into
> OL Controls, Events and Handlers system.
>
> I load my vector data from GML source and show it on the map, then i
> add some control for interacting with it.
> What I want to do is change my vector objects style when i hover over
> them, which is easy with renderIntent option.
>
> var control = new OpenLayers.Control.SelectFeature(vectorLayer, {
> 	hover: true,
> 	clickout: false,
> 	toggle: false,
> 	multiple: false,
>        renderIntent:
> OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style["select"]),
>        //onSelect: addPopup,
>        //onUnselect: removePopup
> });
>
> map.addControl(control);
> control .activate();
>
> And now comes the tricky part: besides hover over them and change
> their color, I want to be able to add a popup on them when i click
> them (not when i hover),
> that usually works with onSelect and onUnselect params, but its not
> possible to enable both options at the same time.
>
> Also is not possible to add more SelectFeature controls on same layer,
> right?
>
> Can somebody give me some hints/examples how to do this, if its possible at
> all.
>
> Thank you,
>  Ivan
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>



More information about the Dev mailing list