How to zoom in map in OpenLayerss 3 on click of button?

I want to zoom in and zoom out the map on custom buttons instead of + and - buttons which are on default map.

I tried with:


But it's not working, though it was working in OpenLayers 2.


If you want to zoom in if you click on the map the following should work:

map.on('click', function() {
  • I want to click on button not on map. This button is custom button. – Mr. P Sep 15 '15 at 10:23
  • 1
    Thank you. it is working. map.getView().setZoom(map.getView().getZoom()+1); – Mr. P Sep 15 '15 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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