<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Yep. But it will work as expected if you swap the order in
    SelectFeature. Of course, needing to do that is not expected. <br>
    <br>
    Not that this might not be a nice feature to have. It could actually
    be very useful be able to click features underneath a layer. <br>
    <br>
    -Mike<br>
    <br>
    <div class="moz-cite-prefix">On 7/11/2012 3:00 PM,
      <a class="moz-txt-link-abbreviated" href="mailto:openlayers-dev-request@lists.osgeo.org">openlayers-dev-request@lists.osgeo.org</a> wrote:<br>
    </div>
    <blockquote class=" cite"
      id="mid_mailman_43_1342033202_17918_openlayers_dev_lists_osgeo_org"
cite="mid:mailman.43.1342033202.17918.openlayers-dev@lists.osgeo.org"
      type="cite">
      <pre wrap="">True! 

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
rectangle!

Xavier


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