[OpenLayers-Users] SelectFeature on Overlapping Layers

Christopher Schmidt crschmidt at metacarta.com
Mon Jan 18 10:40:38 EST 2010


On Mon, Jan 18, 2010 at 01:00:31PM +0100, Marc Jansen wrote:
> Hi Afroz,
> 
> maybe the Vector.RootContainer-Layer is of any help to your problem:
> http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLayers/Layer/Vector/RootContainer-js.html

No, he's already using that implictly via SElectControl.


Afroz: What do you *expect* the behavior to be? What you
are seeing is the way the SelectFeature control works; 
if you want something different than that, you're going to
have to write some application level logic. One thing that
I often do is write something which, given a feature, iterates
over all layers, and does an intersection test on all features
to select additional ones, but that's obviously Not Fast if
you have many many features, and doesn't belong in core.

-- Chris 

> Regards,
> Marc
> 
> 
> afrozk wrote:
> > Hi,
> > 	I have two vector layers Layer1 and Layer2 on a country base map.
> > 	I use the following code to fetch data for the layers.
> > 	var selectControl = new OpenLayers.Control.SelectFeature(
> > 				[Layer1, Layer2],
> >                 {
> >                     toggle: true,
> >                     multiple: true, 
> > 					hover: true,
> > 					onSelect: getLayerDetails
> > 				}
> > 				
> > 			);
> > 			
> > 		
> > 		function getLayerDetails(feature) {
> > 			alert(feature.attributes.name);
> > 		}
> > 		
> > 	The above function gives me data correctly when i hover on each independant
> > layers, but
> > 	there are certain areas on the map where some parts of Layer1 and Layer2
> > overlap.
> > 	When I hover on the overlap, I always get the data for Layer1.
> > 	I read here in http://docs.openlayers.org/library/overlays.html, under
> > Interaction section that ,
> > 	there is no support for selecting features from more than a single vector
> > layer at a time, as of OL 2.7.
> > 	
> > 	Is there a way in OL 2.8 by which I can get data for the underlying Layer2
> > as well.
> > 	Or is there a workaround (for the overlap area) by which can I get the data
> > for the a particular layer based on which layer was hovered previously.
> >
> > Any help would be highly appreciated. 
> > 	
> > 	
> > 	
> > Thanks and regards
> > Afroz Kannancheri Kodiyathur
> > 	
> > 	
> >   
> 
> 
> -- 
> 
> 
>   Dipl.-Geogr. Marc Jansen
>   - Anwendungsentwickler -
> 
>   terrestris GmbH & Co. KG
>   Irmintrudisstraße 17
>   53111 Bonn
> 
>   Tel:    ++49 (0)228 / 96 28 99 -53
>   Fax:    ++49 (0)228 / 96 28 99 -57
> 
>   Email:  jansen at terrestris.de
>   Web:    http://www.terrestris.de
> 
>   Amtsgericht Bonn, HRA 6835
>   Komplementärin:  terrestris Verwaltungsgesellschaft mbH
>   vertreten durch: Hinrich Paulsen, Till Adams  
> 
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list