1

How to zoom to max extent on click of button in openlayers-3?

I tried with

function zoomtoextent(){
//map.zoomToMaxExtent(); 
if(globalbBox==null)
    {
    var bBox = new OpenLayers.Bounds(
           68.14806781208101, 20.118149140613397,
        74.47891169978561, 24.722655175866358
    );
    map.zoomToExtent(bBox);
    map.zoomTo("7");
    globalbBox = bBox;

    }
else
    {
        map.zoomToExtent(globalbBox);
    }
}

This was working fine with openlayers-2 but with openlayers-3 it is not working.

1 Answer 1

1

OpenLayer.Bounds doesn't exist anymore.

Currently you can do (if your map use EPSG:4326):

function zoomtoextent() {
  map.getView().fit([68, 20, 74, 24]);
}

See api

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.