Saturday, 2 December 2017

Zoom in/out on click in OpenLayers 3?



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:


onclick="map.zoomIn();"

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



Answer



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


map.on('click', function() {
map.getView().setZoom(map.getView().getZoom()+1);

});

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...