[OpenLayers-Dev] FEATURE SELECTION FROM WMS LAYER

Eric Lemoine eric.c2c at gmail.com
Thu Dec 6 15:45:11 EST 2007


On Dec 6, 2007 6:43 PM, Ganesh Jothikumar <ganeshjothikumar at yahoo.com> wrote:
>
> Hi
>
>      I am using OpenLayers to develop a GIS. I am using GeoServer as teh WMS
> Server and PostGIS as the database. I have point, line and polygon
> information stored in PostGIS. For example I have a set of points and I use
> WMS to display the point features in teh UI using OL
>
>
> untiled_devices = new OpenLayers.Layer.WMS(
> "Nodes", "http://localhost:8080/geoserver/wms",
> {
>      transparent: 'true',
>      singleTile: 'true',
>      format: 'image/png'
> },
> isBaseLayer: false}
> );

One comment before going further: you're mixing up params and options.
Params are sent to the WMS server, while options just configure the
layer's object in OpenLayers. Your WMS layer should be created as
follows:

layer = new OpenLayers.Layer.WMS('nodes', 'http://localhost:8080/geoserver/wms',
    {transparent: true, format: 'image/png'},
    {isBaseLayer: false, singleTile: true}
);


> Now I want the user to select some points and do some actions appropriately.
> Now teh requirement is to be able to select independent features from the
> layer as shown above. Say for example I display 20 points using the above
> layer the user should be able to select some 10 out of them by clicking on
> them.

You can use WMS GetFeature info to get information on some point
location. See this example
<http://www.openlayers.org/dev/examples/getfeatureinfo.html>.

> Also as and when he selects the selection needs to be shown. The

Sounds like you want a new image from geoserver with the selected
features highlighted. I don't think this is feasible with pure WMS.

> similar requirement is there for otyher shapes also like polygon and
> lines..What I want is from the WMS layer got from GeoServer I need to
> interpret the variuos features based on user interaction..

So use WFS :-) Alternatively, you can create your own service, and
have your js code send a request to that service on each click on the
map (or as the mouse goes over the map). Your service can basically
checks what's located at your mouse position and sends features back.
Once the js code has the response, it can for example draws the
received features in a vector layer overlaid on top of your WMS layer.
We do all that in MapFish (www.mapfish.org) ;-)

> Also is it posible to have hyperlink over the features of a layer for
> example I want to have hyperlink for all points in the layer so that user
> when he clicks it goes to a popup page..

Once you have features displayed in a vector layer, you have lots of
possibilities. For example, you can popups when clicking on features,
with any HTML (including hyperlinks) you want in that popup.

--
Eric



More information about the Dev mailing list