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 have WMS layer and want use zoomToExtent after CQL filter. So i gonna get bbox from geoserver.

wms = new OpenLayers.Format.WMSCapabilities();
success: function(e){
var response =;
var capability = response.capability;
for (var i=0, len=capability.layers.length; i<len; i+=1) { 
var layerObj = capability.layers[i]; 
if ( === 'filedata') { 

But zoomToExtent dont wanna work with lon lat, so how to get bbox in meters? My map showed in epsg900913.

share|improve this question
The answer is the same as your previous question - Zooming the map after filter WMS doesn't work the way that you seem to think. – iant May 21 '12 at 7:47
in last time im ask this question uncorrectly. But today i see project when its worc fine. – Kliver Max May 21 '12 at 8:18
up vote 2 down vote accepted

you should use transform method for getting your result in meters.

OpenLayers.Projection.transform = function( point,
    dest    )

Transform a point coordinate from one projection to another. Note that the input point is transformed in place.


point {{OpenLayers.Geometry.Point> | Object} An object with x and y properties
representing coordinates in those dimensions.

sourceProj {OpenLayers.Projection} Source map coordinate system

destProj {OpenLayers.Projection} Destination map coordinate system

Example :

    var lonlat = new OpenLayers.LonLat(-3.57138, 39.8384);
    lonlat.transform(map.displayProjection, map.baseLayer.projection);
    map.setCenter(lonlat, 5);

i hope it helps you...

share|improve this answer
Strange thing. i get correct bbox in lon lat. After transform i get meters bbox its correct too. But when use zoomToExtent nothing heppens. Im add Controls.MousePosition and mouse show that my map out of extent which i get. Whats wrong? – Kliver Max May 21 '12 at 8:16
And another question if i have only polygons im must use setCenter()? – Kliver Max May 21 '12 at 8:21
try to get bobunding box center lon-lat. example: map.getExtent().getCenterLonLat()...then set it to center... – Aragon May 21 '12 at 8:30
transform(projection,displayProjection) dont working. Try convert lonlat in meters but its not heppening. – Kliver Max May 21 '12 at 10:03
can you share your error you have met? in normal situation it works very well – Aragon May 21 '12 at 10:21

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.