Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a web gis application (openlayers/geoserver) to display a layer of properties, I need to add a functionality of search in it based on the name of the owner.

A list of similar names owners with address should be displayed and when i click a particular item the map should be zoomed on the particular property location.

The problem is that i want this functionality using WMS. (I do not want it in WFS as the vector layer can be copied using QGIS or other tools, it is not secure). Please let me know how will this be possible using WMS.

share|improve this question

Do you use Postgis? Try Ajax request. Send a name of the owner from input box to php script that return to you bounding box of the property. Than you can use that bbox in openlayers.

 // this function is written in old way - using jQuery recommended

function takePropertyGeomBasedOnName(name) {

if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4 && xmlhttp.status==200)
//write response to 'geojson' variable
var geojson = xmlhttp.responseText;
//change json to  js variables
eval("var coord = ("+geojson+")");
var geometria = coord.geometria;

if (geometria == ''){
     alert("No properties");
} else {




Here you have php script getGeometry.php. Adjust that code for your needs. This is just quick solution.

$dbconn = pg_connect ("host=XXX port=5432 dbname=XXX user=XXX password=XXXX");
if (!$dbconn) {
    die("Error in connection: " . pg_last_error());

$query = "SELECT st_Extent(the_geom) FROM XXX WHERE \"ownerName\" = '".$name."'";
$result = pg_query($dbconn, $query);
if (!$result) {
    die("Error in SQL query: " . pg_last_error());
while ($row = pg_fetch_array($result)) {
    $geometria = $row[0] ;
echo "{ 'geometria':'$geometria'}";
share|improve this answer
yes i am using postgis, please send details about ajax – user9678 Aug 22 '12 at 6:59
Well... AJAX is the method that allows you to make bd query without reloading the whole page. Check code above to figure it out – Odoakr Aug 22 '12 at 7:52

You can add a custom param to your WMS layer called CQL_FILTER. It's a Geoserver extension to WMS which allows to specify a filter based on a SQL-like language called Common Query Language.

The documentation, along with examples and a sandbox is available at:

CQL_FILTER will work an any vector layer type supported by Geoserver (shapes, postgis, etc).

Please note that when you use a CQL_FILTER images will be generated on demand and GeoWebCache will not cache them, so performance might be impacted depending on the size of your dataset and complexity of the query.

share|improve this answer
Thanks for the answer, this option is fine for me as a programmer, but i am looking for a solution for a simple user, like searching for places in google earth. – user9678 Aug 22 '12 at 7:15
Functionality is there, the interface is up to you – unicoletti Aug 22 '12 at 9:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.