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

dr rykovd at gmail.com
Wed Oct 26 02:54:25 EDT 2011


Adding of multiple controls to the map is supported. You should create 2
SelectFeature control with different "layer" property. The first control for
highlighting features should to be configured with hover:true option
(highlightOnly property is optional) and second with hover:false.

Example of first control:

    selectFeatureHover = new OpenLayers.Control.SelectFeature(
        layer_hover,
        {
            hover: true,
            highlightOnly: true,
            eventListeners: {
                featurehighlighted: function (e) {
                    ...
                },
                featureunhighlighted: function () {
                    ...
                }
            }
        }
    );

Second control:

    selectFeatureClick = new OpenLayers.Control.SelectFeature(
        click_layer,
        {
            hover: false,
            onSelect: function (f) {
                ...
            },
            onUnselect: function () {
                ...
            }
        }
    );

-----
Denis Rykov
NextGIS
http://www.nextgis.org/
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/SelectFeature-on-multiple-layers-with-different-events-click-hover-tp6908197p6931703.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list