mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
stickers clearing on toggling button
This commit is contained in:
parent
7fc53444a8
commit
21532ba240
2 changed files with 31 additions and 10 deletions
|
@ -42,6 +42,9 @@ export class Editor {
|
||||||
},
|
},
|
||||||
[MODES.SHOTTER]: {
|
[MODES.SHOTTER]: {
|
||||||
start: this.shotter.makeShot,
|
start: this.shotter.makeShot,
|
||||||
|
},
|
||||||
|
[MODES.STICKERS]: {
|
||||||
|
toggle: this.clearSticker,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,9 +71,13 @@ export class Editor {
|
||||||
|
|
||||||
changeMode = mode => {
|
changeMode = mode => {
|
||||||
if (this.mode === mode) {
|
if (this.mode === mode) {
|
||||||
this.disableMode(mode);
|
if (this.switches[mode].toggle) {
|
||||||
this.setMode(MODES.NONE);
|
this.switches[mode].toggle(); // if we have special function on mode when it toggles
|
||||||
this.mode = MODES.NONE;
|
} else {
|
||||||
|
this.disableMode(mode);
|
||||||
|
this.setMode(MODES.NONE);
|
||||||
|
this.mode = MODES.NONE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.disableMode(this.mode);
|
this.disableMode(this.mode);
|
||||||
this.setMode(mode);
|
this.setMode(mode);
|
||||||
|
@ -129,10 +136,16 @@ export class Editor {
|
||||||
this.setActiveSticker(sticker);
|
this.setActiveSticker(sticker);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
clearSticker = () => {
|
||||||
|
this.setSticker(null);
|
||||||
|
};
|
||||||
|
|
||||||
clearAll = () => {
|
clearAll = () => {
|
||||||
this.poly.clearAll();
|
this.poly.clearAll();
|
||||||
this.router.clearAll();
|
this.router.clearAll();
|
||||||
|
this.stickers.clearAll();
|
||||||
|
|
||||||
|
this.setSticker(null);
|
||||||
this.changeMode(MODES.NONE);
|
this.changeMode(MODES.NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ export class Stickers {
|
||||||
|
|
||||||
this.layer.addTo(this.map);
|
this.layer.addTo(this.map);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
createOnClick = e => {
|
// createOnClick = e => {
|
||||||
if (!e || !e.latlng) return;
|
// if (!e || !e.latlng) return;
|
||||||
|
//
|
||||||
const { latlng } = e;
|
// const { latlng } = e;
|
||||||
this.createSticker({ latlng });
|
// this.createSticker({ latlng });
|
||||||
};
|
// };
|
||||||
|
|
||||||
createSticker = ({ latlng, sticker }) => {
|
createSticker = ({ latlng, sticker }) => {
|
||||||
const marker = new Sticker({
|
const marker = new Sticker({
|
||||||
|
@ -41,4 +41,12 @@ export class Stickers {
|
||||||
this.map.removeLayer(ref.sticker);
|
this.map.removeLayer(ref.sticker);
|
||||||
this.stickers.splice(index, 1);
|
this.stickers.splice(index, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
clearAll = () => {
|
||||||
|
const target = [...this.stickers];
|
||||||
|
target.map(sticker => {
|
||||||
|
this.deleteStickerByReference(sticker);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue