Skip to content

Commit

Permalink
Zoom to box w/ OL8 (#4006)
Browse files Browse the repository at this point in the history
Co-authored-by: nboisteault <[email protected]>
  • Loading branch information
3liz-bot and nboisteault authored Dec 5, 2023
1 parent eb2fd2d commit 8725852
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions assets/src/modules/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { getPointResolution } from 'ol/proj.js';
import DragPan from 'ol/interaction/DragPan.js';
import MouseWheelZoom from 'ol/interaction/MouseWheelZoom.js';
import DoubleClickZoom from 'ol/interaction/DoubleClickZoom.js';
import DragZoom from 'ol/interaction/DragZoom.js';
import { defaults as defaultInteractions } from 'ol/interaction.js';
import { always } from 'ol/events/condition.js';

/** Class initializing Openlayers Map. */
export default class Map extends olMap {
Expand Down Expand Up @@ -35,6 +37,19 @@ export default class Map extends olMap {
target: 'newOlMap'
});

// Zoom to box
const dragZoom = new DragZoom({
condition: always
});

document.querySelector('#navbar .pan').addEventListener('click', () => {
this.removeInteraction(dragZoom);
});

document.querySelector('#navbar .zoom').addEventListener('click', () => {
this.addInteraction(dragZoom);
});

this._newOlMap = false;

this._refreshOL2View = () => {
Expand Down
4 changes: 4 additions & 0 deletions lizmap/www/assets/css/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,10 @@ a.btn.btn-opacity-layer.active {
padding: 4px;
}

.ol-dragzoom{
border: solid 2px rgba(255, 0, 0, 0.5);
}

/*Loading window*/
#ui-dialog-title-loading {
font-size:0.7em;
Expand Down

0 comments on commit 8725852

Please sign in to comment.