Search code examples
openlayers

Cannot Select drawn features on multiple layers


I'm using Openlayers 2.12 with Firefox 18.0.

I'm just adding an EditingToolbar to this example :

http://openlayers.org/dev/examples/select-feature-multilayer.html

So basically I change this :

map.addLayers([wmsLayer, vectors1, vectors2]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
selectControl = new OpenLayers.Control.SelectFeature
(
    [vectors1, vectors2],
    {
        clickout: true, toggle: false,
        multiple: false, hover: false,
    }
);

map.addControl(selectControl);
selectControl.activate();

by adding one line :

map.addLayers([wmsLayer, vectors1, vectors2]);
map.addControl(new OpenLayers.Control.EditingToolbar(vectors2));
map.addControl(new OpenLayers.Control.LayerSwitcher());
selectControl = new OpenLayers.Control.SelectFeature
(
    [vectors1, vectors2],
    {
        clickout: true, toggle: false,
        multiple: false, hover: false,
    }
);

map.addControl(selectControl);
selectControl.activate();

And now I can't select features (that I draw) correctly on any layers, got any leads ?


Solution

  • The problem that you have mentioned is derived from dragging handler activation when you adding Editing Toolbar to map.

    map.addControl(new OpenLayers.Control.EditingToolbar(vectors2));

    you have two ways to get rid of this problem.

    first way:

    add a new tool to activating and toggling select control.

    second way:

    try to set false to drag prototype.

    OpenLayers.Handler.Drag.prototype.stopDown = false;
    

    i hope it helps you...