Skip to content

Commit

Permalink
Merge pull request 3liz#5104 from nboisteault/draw_translate
Browse files Browse the repository at this point in the history
Draw: add translate interaction active by default
  • Loading branch information
Gustry authored Dec 11, 2024
2 parents b4bec8d + d51cfad commit e0768de
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 e0768de

Please sign in to comment.