In the popup & tooltip behaviour, the layers parameter that is passed to the creator of the SelectFeature Control passes an Array, even if there is only 1 layer in that Array.

This patch passes the layers variable as a Layer when there is only 1 layer.

We ran into issues with this using our openlayers_geosearch vector layer + another vector layer with a popup/tooltip behaviour.

With this patch, both layers can have their own SelectFeature Control.

Files: 
CommentFileSizeAuthor
#1 SelectFeatureperlayer-1393460.patch1.2 KBbatje
Test request sent.
[ View ]

Comments

Title:Add Popup & Hoover behaviour only to single layer, instead of array of 1 layerAllow different SelectFeature Controls for different layers
Status:Active» Needs review
StatusFileSize
new1.2 KB
Test request sent.
[ View ]

Like this title better. Patch attached.

Status:Needs review» Needs work

Hey @batje. Thanks for the patch, but I am not sure what problem this solves. The SelectFeature control can handle an array or a single layer. What specific issues were you having? Also, is this true of 7.x too?

http://dev.openlayers.org/docs/files/OpenLayers/Control/SelectFeature-js...

Hey @batje. I think you meant for this comment to be here:

The array will work, but it will attach the SelectFeature to all layers on the map.

From code. Check the initLayer function in this javascript file:
http://dev.openlayers.org/sandbox/camptocamp/mobile/trunk/lib/openlayers...

That shows that the whole array of layers is put in a _container div (or a RootContainer vector layer).

The result of this is that the Click event on a single layer does not cancel consecutive clicks. So if you have 2 layers, and click the top one, then the click event also occurs on the second layer.

When we build a map with our geosearch module and our GetFeatureInfo functionality from the wms module and a normal Drupal layer, that was causing issues. After you clicked a search result, you did not want to also do a WMS Getfeatureinfo request as well.

This patch solved that (rather obscure) issue for us.

The reason why this is happening is that if you add 2 layers to the SelectFeature, the click event should not be cancelled by OpenLayers (well, its should, once you reach the last one, but its not implemented that way).

When you add only 1 layer, the Click event *is* cancelled by OpenLayers, which is good.

Status:Needs work» Fixed

This has been committed to D6 and D7. Thanks for the patch!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.