Wow sorry. Forget the first line:

activeLayer = new OpenLayers.Layer.WMS(

      layername, layerurl,
      {
         width: map.size.w,
         srs: map.projection,
         layers: layername,
         height: map.size.h,
         styles: '',
         format: 'image/png',
         transparent: false
      }
      );

 // for example: conditions = "igh>  5000 AND BBOX('the_geom',1,2,3,4)"
 activeLayer.mergeNewParams({
         'cql_filter': conditions
      });

bounds = new
OpenLayers.Bounds(mapbounds[0],mapbounds[1],mapbounds[2],mapbounds[3
]);

map.zoomToExtent(bounds);


'mapbounds' is only an array with minx, miny, max, maxy values inside.

According to Wally, trying this didn't work:

var d = new Date();

activeLayer.mergeNewParams({
         'cql_filter': conditions,
         'date': d.getTime()
      });


Thanks!


El 02/02/2011 21:30, Ian Turton escribió:
On Wed, Feb 2, 2011 at 2:25 PM, Francisco M. Santana Verona
<[email protected]>  wrote:
Hello list!

I apply a filter to one layer and works nice. I want to maximize the bounds
where I applied the filter, like this:

mapbounds = new OpenLayers.Bounds(...);

activeLayer = new OpenLayers.Layer.WMS(
       layername, layerurl,
       {
          width: map.size.w,
          srs: map.projection,
          layers: layername,
          height: map.size.h,
          styles: '',
          format: 'image/png',
          transparent: false
       }
       );

  // for example: conditions = "igh>  5000 AND BBOX('the_geom',1,2,3,4)"
  activeLayer.mergeNewParams({
          'cql_filter': conditions
       });

bounds = new
OpenLayers.Bounds(mapbounds[0],mapbounds[1],mapbounds[2],mapbounds[3
]);

map.zoomToExtent(bounds);

The filter works fine, but the zoom is restored too quickly after apply it.
It's applied, but the layer restore to the initial view instantly.

I don't think the way you create bounds is right, mapbounds is a
Bounds object 
(http://dev.openlayers.org/docs/files/OpenLayers/BaseTypes/Bounds-js.html)
so I suspect mapbounds[0] means anything.

Is there a reason not to just zoom to mapbounds?

Also we really need to see all the code to be sure what else is
happening, for example is there a call to map.zoomTo(level) later?

Ian
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to