On Wed, Nov 18, 2009 at 12:56:34PM -0800, Dragan Podvezanec wrote:
> 
> Hi all.
> 
> I have 10 WMS layers (polygons) which do not overlap. I'm trying to panZoom
> to the center of the polygon which user clicked. I registered
> "featureselected" events on all WMS layers, like this:
> 
> for(var i in map.layers[layer]) {             
>                                               mapa.events.layers[layer] = new 
> OpenLayers.Control.GetFeature({
>                                               protocol: 
> OpenLayers.Protocol.WFS.fromWMSLayer(map.layers[layer],{
>                                                       geometryName: 
> 'geometry',
>                                                       srsName: "EPSG:900913"
>                                                       }),
>                                                       hover: false
>                                               });
> 
>                                               
> mapa.events.layers[layer][i].events.register("featureselected", this,
> function(e) {
> 
>                                               var objekt = e.feature;
>                                               var bbox = 
> (objekt.geometry.bounds);
>                                               var newcenter = 
> (bbox.getCenterLonLat());
>                                               mapa.panTo(newcenter);
> }
> 
> And this works. Map gets centered to the object that I have clicked. But as
> I see, there are 10 post request to Geoserver, featureselected is triggered
> on every WMS layer. Is this not an overhead? Why is event featureselected
> triggered, even I have clicked outside a layer?

The featureselected event *isn't* triggered -- that event just 
centers the map. The event that requests the datai s the GetFeature control.

The GetFeature Control has no way of knowing that there is a feature under
your cursor without asking the server.  What you have downloaded is just 
images -- OL knows nothing about the geometries.

As such, it has to ask the server for each of the layers whether there is an
intersecting feature.

> 1. Is this normal behavior?
> 2. What would happen if I have 100 layers?

Probably what you would expect.

> 3. Should I use different approach? (To make invisible WFS layers on top of
> WMS layers, and then register featureselected to WFS layers?)

You could, assuming 'invisible' layers actually get select events (I don't
know if they do.)

> -- 
> View this message in context: 
> http://n2.nabble.com/WFS-fromWMSLayer-selection-question-tp4028249p4028249.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [email protected]
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to