I have implemented zoom in by box selection using openlayers 4 , like this

$('#zoomin').click(function () {
        // var currentZoomLevel = map.getView().getZoom();
        //map.getView().setZoom(currentZoomLevel + 1);
        dragBoxInteraction = new ol.interaction.DragBox({
            // condition: ol.events.condition.platformModifierKeyOnly
        dragBoxInteraction.on('boxend', function () {           
            var extent = dragBoxInteraction.getGeometry().getExtent();
            map.getView().fit(extent, map.getSize());
            //source.forEachFeatureIntersectingExtent(extent, function (feature) {
            //    console.log(feature);


I need to implement zoom out by box , i've searched a lot , but no luck with openlayers , by box selection i need to zoom out to the area which user selects

Your Answer

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

Browse other questions tagged or ask your own question.