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 draw in the init() function a WMS layer an add it to the map:

var lyr_osm = {};
var map = {};

$(document).ready(function () {
    map = new OpenLayers.Map('map',
                    numZoomLevels: 18,
                    projection: googleMercator

    lyr_osm =new OpenLayers.Layer.OSM("OSM");

       lyr_state = new OpenLayers.Layer.WMS("State",
           'VERSION' : '1.1.0',
           layers: "us_admin:states",
//           style: style_state_polyg,
           format: "image/png",
           transparent: true
               {isBaseLayer: false,
                visibility: false,
                sphericalMercator: true,                        
                opacity: 0.5}

    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.addControl(new OpenLayers.Control.MousePosition());
    map.addLayers([lyr_osm, lyr_state]);
    var mapCenter = new OpenLayers.LonLat(-97, 40);
    mapCenter.transform(wgs84, googleMercator);

Then onclick of an input button I pass a location from a google Autocompleter, transform it to EPSG900913, and use it to filter the WMS layer:

 $(document).ready(function () {
       sdata = $('#searchTextField').val();
    if( sdata == undefined || sdata == 'Enter an address...' || sdata < 4 ){
    alert('Please insert or choose an address to proceed.');
    } else {

       latlong = String(ads.d);
       longlat = latlong.split(",");
       long = String(longlat[1]);
       slong = long.replace(")", "");
       lat = String(longlat[0]);
       slat = lat.replace("(", "");
       position = new OpenLayers.LonLat(slong, slat);
       position.transform(wgs84, googleMercator);
       var mlat = String(position);
       mlatt = mlat.replace("lon=","")
       mlattt = mlatt.replace("lat=","");
       mlatttt = mlattt.replace(","," ");

  lyr_state.mergeNewParams({cql_filter: "contains(geom,POINT(-10625033.067 3488845.830))"});
  lyr_state.mergeNewParams({visibility: true});


The problem is that onclick returns me an aocean area, and not what I want. The new parameters are updated in the DOM but I do not see the result.

Any hint? Thanks!

Geoserver is 2.2 with no error showing.

Java = Oracle Corporation: 1.7.0_11 (Java HotSpot(TM) 64-Bit Server VM)

Any hint? Thanks!

share|improve this question
If you paste the WMS request (look in firebug) into your browser what do you get back? – iant Jan 21 '13 at 11:01
You have already defined the CQL filter when you defiend the WMS layer. Why are you merging the same CQL filter once again? – Devdatta Tengshe Jan 21 '13 at 11:36
For iant, no error returns in Firebug. – Niculita Mihai Jan 21 '13 at 12:14
For Devdatta Tengshe, It is my mistake, in the code the filter is commnented. I will edit. – Niculita Mihai Jan 21 '13 at 12:15

Your Answer


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

Browse other questions tagged or ask your own question.