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

wms = new OpenLayers.Format.WMSCapabilities();
OpenLayers.Request.GET({
url:"http://localhost:8080/geoserver/wms/filedata?request=GetCapabilities",
success: function(e){
var response = wms.read(e.responseText);
var capability = response.capability;
for (var i=0, len=capability.layers.length; i<len; i+=1) { 
var layerObj = capability.layers[i]; 
if (layerObj.name === 'filedata') { 
    map.zoomToExtent(OpenLayers.Bounds.fromArray(layerObj.llbbox)); 
    break; 
} 
}
}
});

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

1 Answer

up vote 2 down vote accepted

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

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

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

Parameters

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
show 2 more comments

Your Answer

 
discard

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.