Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_7] Zoom to box w/ OL8 #4006

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading