[GIS] select feature info on user defined polygon

openlayers-2wfswms

Ok so I have a Openlayers App which is displaying few of the features and I now want to give the user the freedom to create a Box or polygon. All the features which are overlapped by this user defined box, I wish to export the data and then display it onto a table in the html.

  1. Is there any OL example to such application requirement?
  2. Which would be better to extract the feature info, WFS or WMS?

I know it can be done in GMaps but I have OSM and GMaps both as base maps so I require a OL functionality.

Best Answer

Custom Control

Hold Shift button to create the rectangle

http://openlayers.org/dev/examples/custom-control.html

You will get the bound box lat/lng response.

You can use this response to retrieve features.

Dynamic POIs via a Text Layer

In this example the data you see is retrieved from a text file but could be from a geojson,kml or database/api or geoserver

http://openlayers.org/dev/examples/dynamic-text-layer.html

Get WFS from Geoserver (Web Feature Service)

This get the WFS service from Geoserver and displays in Openlayers

http://openlayers.org/dev/examples/getfeature-wfs.html

use the Shift key to add features to the selection,

You will want to combine the entire set of examples to do your 'select user defined polygon' map.