<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
When I render a layer as a Canvas it no longer respects the layer
index. <br>
<br>
In my case, the Canvas layer is made up of polygons and a separate
layer above it is made up of points. Any points within polygons
cannot be selected -- only the surrounding polygon gets selected.<br>
<br>
I do not have this problem if the polygon layer is rendered as
something other than a Canvas.<br>
<br>
This problem is caused by the order of the layers in the array sent
to OpenLayers.Control.SelectFeature. The workaround is ordering the
layers array so that the Canvas layer comes after layers that are
above it in the layer index.<br>
<br>
In other words, even though I add layers to the map like this: <br>
map.addLayers([canvas_layer, point_layer])<br>
<br>
I have to add layers to the control like this: <br>
map.addControl(new OpenLayers.Control.SelectFeature([point_layer,
canvas_layer]))<br>
<br>
To reproduce this problem do the following.<br>
<br>
1. Go to:
<a class="moz-txt-link-freetext" href="http://openlayers.org/dev/examples/select-feature-multilayer.html?renderer=Canvas">http://openlayers.org/dev/examples/select-feature-multilayer.html?renderer=Canvas</a><br>
<br>
2. Swap the order of vectors1, vectors2 in lines 62 & 65 so they
look like this:<br>
<br>
(line 62) map.addLayers([wmsLayer, vectors2, vectors1]);<br>
...<br>
(line 65) selectControl = new OpenLayers.Control.SelectFeature(<br>
[vectors2, vectors1],<br>
<br>
Changing addLayers puts the markers above the squares. Changing
SelectFeature disallows markers within squares to be selected, even
though they are above the squares. You will only see this problem if
you render the layers as Canvases (i.e. include "?renderer=Canvas"
in the url).<br>
<br>
Considering that layer order in SelectFeature has no effect on
layers not rendered as Canvases, this is either a bug or requires
some documentation for SelectFeature.<br>
<br>
This was also an issue in OL 2.11, but 2.12 improved the situation.
In 2.11 if you turned off the Canvas layer it persisted even though
you could not see the layer! If you panned the map, it would finally
go away and you could click the layers below.<br>
<br>
-Mike<br>
<br>
<br>
Reference:<br>
OpenLayers.Control.SelectFeature<br>
<a class="moz-txt-link-freetext" href="http://dev.openlayers.org/docs/files/OpenLayers/Control/SelectFeature-js.html#OpenLayers.Control.SelectFeature.OpenLayers.Control.SelectFeature">http://dev.openlayers.org/docs/files/OpenLayers/Control/SelectFeature-js.html#OpenLayers.Control.SelectFeature.OpenLayers.Control.SelectFeature</a><br>
<br>
OpenLayers Select Feature on Multiple Layers Example<br>
<a class="moz-txt-link-freetext" href="http://openlayers.org/dev/examples/select-feature-multilayer.html?renderer=Canvas">http://openlayers.org/dev/examples/select-feature-multilayer.html?renderer=Canvas</a><br>
<br>
<br>
</body>
</html>