[OpenLayers-Users] Problem with SelectFeature control

Bob Farrell robertanthonyfarrell at gmail.com
Tue Mar 8 11:50:57 EST 2011


Hi there,

Having great success with OpenLayers but have found one minor issue
which may be a bug but hopefully is just a mistake on my part.

Firstly, here's my code (or here with highlighting if you prefer:
http://bpaste.net/show/SjHd7xV7pZUnJNzYcI89/):

        var highlightCtrl = new OpenLayers.Control.SelectFeature(layer, {
            hover: true,
            highlightOnly: true,
            renderIntent: "temporary"
        });

        var selectControl = new OpenLayers.Control.SelectFeature(layer,
            {
             multiple: true,
             toggle: true,
             clickout: false,
             onSelect: function (e) {
                that._selectedRegions[e.data.id] = true;
                that.changeCallback({id: e.data.id, selected: true},
                                    that._selectedRegions);
                },
             onUnselect: function (e) {
                that._selectedRegions[e.data.id] = false;
                that.changeCallback({id: e.data.id, selected: false},
                                    that._selectedRegions);
                }
            }
        );
        this._map.addControl(highlightCtrl);
        this._map.addControl(selectControl);
        highlightCtrl.activate();
        selectControl.activate();

The problem I'm seeing is that when I click a region to select it and
then click again to deselect it, when I hover back over that region
and then back out of it then its colour is restored to the "selected"
colour, even though no onSelect event is triggered.

Am I doing something wrong here ?

Let me know if I can provide any more info.

Thanks very much,


More information about the Users mailing list