I try to automatically zoom map to maximum extent of layer after adding layer to map. I tried to code like this.
var layer = OpenLayers.Layer.WMS(.......); map.addLayer(layer); map.zoomToExtent(layer.getDataExtent());
But it doesnt' work. I also changed like this
It still doesn't work. What can I do to solve this issue.