[OpenLayers-Users] Problem with multiple SelectFeature controls

Bill Thoen bthoen at gisnet.com
Wed Jan 14 11:42:38 EST 2009


 From the responses I'm getting in the "[OpenLayers-Users] Switching 
Layers Assigned to a SelectFeature Control" thread and some Googling it 
appears that handling multiple vector layers simultaneously in 
OpenLayers is not well supported. In fact, it basically won't work. Only 
one layer of features can be selectable at a time.

What I'm trying is to create only one SelectFeature control, but then 
allow the user to pick which layer they want to be "active". After they 
choose, I destroy the current SelectFeature control and replace it with 
a new SelectFeature control that uses the new layer. It's not elegant, 
but it seems to work.




Joao Duarte wrote:
>
> Hi,
>
> I’ve added several GML layers to the map. Each layer contains data 
> from a KML file. The layers are all displayed well, the problem is 
> when I add the SelectFeature control. I tried adding one control to 
> each layer but this has the problem of only the last added layer gets 
> its control working properly.
>
> The problem seems to be caused by the Feature handler. If you have 
> many Feature handlers, only the one assigned to the top layer will work.
>
> Any suggestions on how I can have multiple SelectFeature controls, 
> each one associated with a different layer, all working?
>
> Best regards,
>
> João Duarte
>
> http://maps.sapo.pt
>




More information about the Users mailing list