[OpenLayers-Users] Highlighting the selected geometry

Lehtonen, Mika mika at digikartta.net
Tue Sep 9 08:42:41 EDT 2008


Yep,
thanks. I am using Geoserver so SLD approach is ok. One stupid question. 
I started to play around with GetFeature, but how can you get just the 
feature you clicked. I tried something similar like in OL example [1], 
but with GetFeature and WFS. So the following is what I tried:

   map.events.register('click', null, function (e) {
      OpenLayers.Util.getElement('nodelist').innerHTML = "Odota hetki...";
          var url =  wfs.getFullRequestString({
               SERVICE: 'WFS',
               VERSION: '1.0.0',
               REQUEST: 'GetFeature',
               OUTPUTFORMAT: 'text/xml; subtype=gml/2.1.2',
               PROPERTYNAME: 'LAYER',
               MAXFEATURES: 3,
               TYPENAME: 'dikanet:karsa_region',
               SRSNAME: 'EPSG:2393',
               BBOX: wfs.map.getExtent().toBBOX()},
                          "http://karsamaki.digikartta.net/asemakaavat/wfs"
                          );
               OpenLayers.loadURL(url,'',this,setHTML);
               Event.stop(e);
               });

   function setHTML(response) {
   OpenLayers.Util.getElement('nodelist').innerHTML = 
response.responseText;
};

But this gives me all the feautures in the current viewport. How can I 
filter out the rest and just take the one I clicked?

- mika -

[1] http://www.openlayers.org/dev/examples/getfeatureinfo.html

Brad Spencer kirjoitti:
> Mika,
>
> Does the map server support (style Layer descriptors) SLDs? If so this is
> the best way to highlight polygons in my experience. Vectors may misalign
> depending on browsers/projections. Also there are capacity limits on vectors
> at the client which can be problematic. The easiest way to make sure this
> does not happen is to have the layer render again via a new SLD. What I do
> is run a GetFeatureinfo(WMS) or getfeaturte(WFS) bring back the list of
> polygons (must have unique identifiers) then I build an SLD on the fly via a
> PHP script save it and then apply that to the current layer. Of course if
> you have the polygon names already accessible in the client (e.g. in a
> select box) then you can just jump to the SLD building part. Works a treat.
>
> Cheers, Brad....
>
> -----Original Message-----
> From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
> Behalf Of Lehtonen, Mika
> Sent: Tuesday, September 09, 2008 5:02 PM
> To: Openlayers Users List
> Subject: [OpenLayers-Users] Highlighting the selected geometry
>
> Hi,
>
> is there any examples available which I could use with the following 
> task? Tried to google, but didn't find any good ones.
>
> I have two wms-layers in my map. The another one includes some polygons. 
> In order to get some info out when clicking the polygon, I built a 
> system which does that. But I would also like to get the selected 
> polygon to render with a different style, so that it'd be sort of 
> highlighted. I thought I could copy it into vector layer having 
> different style. But frankly said, I don't know how to do it. Just 
> learning OL.
>
> - mika -
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   



More information about the Users mailing list