Skip to content

Commit

Permalink
Draw: add translate interaction active by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault authored and github-actions[bot] committed Dec 11, 2024
1 parent b9780e1 commit 2623045
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assets/src/modules/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import GPX from 'ol/format/GPX.js';
import KML from 'ol/format/KML.js';
import WKT from 'ol/format/WKT.js';

import { Draw, Modify, Select } from 'ol/interaction.js';
import { Draw, Modify, Select, Translate } from 'ol/interaction.js';
import { createBox } from 'ol/interaction/Draw.js';

import { Circle, Fill, Stroke, RegularShape, Style, Text } from 'ol/style.js';
Expand Down Expand Up @@ -183,6 +183,10 @@ export class Digitizing {
features: this._selectInteraction.getFeatures(),
});

this._translateInteraction = new Translate({
features: this._selectInteraction.getFeatures(),
});

this._drawStyleFunction = (feature) => {
let color = feature.get('color') || this._drawColor;

Expand Down Expand Up @@ -557,6 +561,7 @@ export class Digitizing {

mainLizmap.map.removeInteraction(this._drawInteraction);

mainLizmap.map.addInteraction(this._translateInteraction);
mainLizmap.map.addInteraction(this._selectInteraction);
mainLizmap.map.addInteraction(this._modifyInteraction);

Expand All @@ -567,6 +572,7 @@ export class Digitizing {
} else {
// Clear selection
this._selectInteraction.getFeatures().clear();
mainLizmap.map.removeInteraction(this._translateInteraction);
mainLizmap.map.removeInteraction(this._selectInteraction);
mainLizmap.map.removeInteraction(this._modifyInteraction);

Expand Down

0 comments on commit 2623045

Please sign in to comment.