fixed stickers editing

This commit is contained in:
muerwre 2019-02-20 13:24:28 +07:00
parent f2758843bf
commit 76d6cb3717
4 changed files with 17 additions and 3 deletions

View file

@ -20,7 +20,7 @@
todo check osrm is up
todo maybe: map preview on save
todo maybe: stickers clusterization?
done maybe: stickers clusterization?
## DONE

View file

@ -48,7 +48,7 @@ export class Editor {
// map, editor: this,
// });
this.stickers = new Stickers({ map, lockMapClicks, triggerOnChange });
this.stickers = new Stickers({ map, lockMapClicks, triggerOnChange, editor: this });
this.router = new Router({
map, lockMapClicks, setRouterPoints: this.setRouterPoints, changeMode, pushPolyPoints
});

View file

@ -60,6 +60,9 @@ export class Sticker {
onMouseDown={this.onDelete}
onTouchStart={this.onDelete}
/>
{
console.log('A?')
}
</div>
</React.Fragment>,
this.element

View file

@ -5,10 +5,11 @@ import icons from '$sprites/icon.svg';
import { clusterIcon } from '$utils/clusterIcon';
export class Stickers {
constructor({ map, lockMapClicks, triggerOnChange }) {
constructor({ map, lockMapClicks, triggerOnChange, editor }) {
this.map = map;
this.layer = layerGroup();
this.triggerOnChange = triggerOnChange;
this.editor = editor;
this.clusterLayer = L.markerClusterGroup({
spiderfyOnMaxZoom: false,
@ -20,6 +21,8 @@ export class Stickers {
iconCreateFunction: clusterIcon,
}).addTo(map);
this.clusterLayer.on('animationend', this.onSpiderify);
this.lockMapClicks = lockMapClicks;
this.stickers = [];
@ -70,6 +73,14 @@ export class Stickers {
dumpData = () => this.stickers.map(sticker => sticker.dumpData());
onSpiderify = () => {
if (this.editor.getEditing()) {
this.startEditing();
} else {
this.stopEditing();
}
};
startEditing = () => {
this.stickers.map(sticker => sticker.startEditing());
};