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_8] Draw: add translate interaction active by default #5116

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
8 changes: 7 additions & 1 deletion assets/src/modules/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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 @@ -158,6 +158,10 @@ export default 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 @@ -536,6 +540,7 @@ export default class Digitizing {

mainLizmap.map.removeInteraction(this._drawInteraction);

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

Expand All @@ -546,6 +551,7 @@ export default 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
Loading