[OpenLayers-Users] SelectFeature working at the same time in two different overlays?

Daniele Forti gruppi at willygroup.org
Wed May 26 05:22:56 EDT 2010


Thanks for the answer,
but that solution in my case works only with Chrome Browser.
In Chrome also works the two-select solution.
With any other browser:
two-select works only the upper layer
one-select doesn't work any layer


-- 
Willy



> Date: Wed, 26 May 2010 09:43:54 +0200
> Subject: Re: [OpenLayers-Users] SelectFeature working at the same time in      two different overlays?
> From: bartvde at osgis.nl
> To: gruppi at willygroup.org
> CC: users at openlayers.org
> 
> Use 1 SelectFeature Control and initialize it with an array of layers.
> 
>     /**
>      * Constructor: OpenLayers.Control.SelectFeature
>      * Create a new control for selecting features.
>      *
>      * Parameters:
>      * layers - {<OpenLayers.Layer.Vector>}, or an array of vector layers.
> The
>      *     layer(s) this control will select features from.
>      * options - {Object}
>      */
> 
> Best regards,
> Bart
> 
> > Hi,
> > I've two overlays, one is a Vector layers of markers built from a kml
> > file,
> > the other is a GML geometric layer from an xml file.
> > I've added a SelectFeature for each layer, but if I add first layer1 then
> > layer2
> > only selectFeature for layer2 work. On otherwise if I add layer2 then
> > layer1
> > only
> > selectFeature for layer1 work, there is a way to make working both layers?
> > Here the code:
> >
> > var layer1 = new OpenLayers.Layer.Vector("Segnalazioni", {
> >     'displayInLayerSwitcher':false,
> >     styleMap: new OpenLayers.StyleMap(style),
> >     projection: map.displayProjection,
> >     strategies: [new OpenLayers.Strategy.Fixed()],
> >     protocol: new OpenLayers.Protocol.HTTP({
> >         url: "file.kml",
> >         format: new OpenLayers.Format.KML({
> >             extractStyles: false,
> >             extractAttributes: true
> >         })
> >     })
> > });
> >
> > var  layer2 = new OpenLayers.Layer.GML(
> >     "GML",
> >     "file.xml",
> >     {
> >         projection: map.displayProjection,
> >         styleMap: myStyleMap,
> >         'displayInLayerSwitcher':false,
> >         'isBaseLayer':false
> >     }
> > );
> >
> >
> >
> >
> > selectControl = new OpenLayers.Control.SelectFeature(
> >     layer2,
> >     {
> >         clickout: true, toggle: true,
> >         multiple: false, hover: true
> >     }
> > );
> >
> > layer2.events.on(
> >     {
> >         "featureselected": function(e) {
> >             alert("Selected.");
> >         },
> >         "featureunselected": function(e) {
> >             alert("Unselected.");
> >         }
> >     }
> > );
> >
> > map.addControl(selectControl);
> > selectControl.activate();
> >
> > select = new OpenLayers.Control.SelectFeature(layer1);
> > layer1.events.on(
> >     {
> >         "featureselected": onFeatureSelect,
> >         "featureunselected": onFeatureUnselect
> >     }
> > );
> >
> > map.addControl(select);
> > select.activate();
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> 
> 
 		 	   		  
_________________________________________________________________
Importa i tuoi amici di Facebook su Messenger
http://www.windowslive.it/importaAmici.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100526/c4037357/attachment.html


More information about the Users mailing list