Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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",
           "http://54.228.241.187:80/geoserver/us_admin/wms",
           {
           '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);
    map.setCenter(mapCenter,4);
}

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 () {
$('#search1').click(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});

  stbound=lyr_state.getDataExtent();
  map.zoomToExtent(stbound);
});
});

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
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.