[OpenLayers-Dev] Canvas + SelectFeature = Bug (OL 2.11/2.12)
Xavier Mamano (jorix)
xavier.mamano at gmail.com
Tue Jul 10 15:29:10 PDT 2012
But the original example also wrong using Canvas: using SVG can not select a
markers if it is below a square, with Canvas you can, as if there were no
> When I render a layer as a Canvas it no longer respects the layer index.
> 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.
> I do not have this problem if the polygon layer is rendered as something
> other than a Canvas.
> 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.
> In other words, even though I add layers to the map like this:
> map.addLayers([canvas_layer, point_layer])
> I have to add layers to the control like this:
> map.addControl(new OpenLayers.Control.SelectFeature([point_layer,
> To reproduce this problem do the following.
> 1. Go to:
> 2. Swap the order of vectors1, vectors2 in lines 62 & 65 so they look
> like this:
> (line 62) map.addLayers([wmsLayer, vectors2, vectors1]);
> (line 65) selectControl = new OpenLayers.Control.SelectFeature(
> [vectors2, vectors1],
> 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
> 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.
> 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.
> OpenLayers Select Feature on Multiple Layers Example
> Dev mailing list
> Dev at .osgeo
View this message in context: http://osgeo-org.1560.n6.nabble.com/Canvas-SelectFeature-Bug-OL-2-11-2-12-tp4985790p4987449.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev