mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-26 03:26:41 +07:00
first import attempts
This commit is contained in:
parent
8da254ff9b
commit
f7e8da1f1f
9 changed files with 57 additions and 6 deletions
|
@ -6,6 +6,8 @@ import { Router } from '$modules/Router';
|
|||
import { Shotter } from '$modules/Shotter';
|
||||
import { DEFAULT_LOGO } from '$constants/logos';
|
||||
|
||||
import { parseStickerAngle, parseStickerStyle } from '$utils/import';
|
||||
|
||||
export class Editor {
|
||||
constructor({
|
||||
container,
|
||||
|
@ -165,4 +167,19 @@ export class Editor {
|
|||
this.setLogo(logo);
|
||||
this.changeMode(MODES.NONE);
|
||||
}
|
||||
|
||||
setData = ({ route, stickers, format = 'old' }) => {
|
||||
if (route) {
|
||||
this.poly.setPoints(route);
|
||||
}
|
||||
|
||||
if (stickers) {
|
||||
stickers.map(({ latlng, ang: angle, style }) => this.stickers.createSticker({
|
||||
latlng,
|
||||
angle: parseStickerAngle({ angle, format }),
|
||||
sticker: parseStickerStyle({ style, format }),
|
||||
}));
|
||||
}
|
||||
this.map.map.fitBounds(this.poly.poly.getBounds());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,11 @@ export class Poly {
|
|||
this.lockMapClicks(true);
|
||||
};
|
||||
|
||||
setPoints = latlngs => {
|
||||
if (!latlngs || latlngs.length <= 1) return;
|
||||
this.poly.setLatLngs(latlngs);
|
||||
};
|
||||
|
||||
pushPoints = latlngs => {
|
||||
const { map } = this;
|
||||
const simplified = simplify({ map, latlngs });
|
||||
|
|
|
@ -7,9 +7,9 @@ import stickers from '$sprites/stickers.svg';
|
|||
|
||||
export class Sticker {
|
||||
constructor({
|
||||
latlng, deleteSticker, map, lockMapClicks, sticker
|
||||
latlng, deleteSticker, map, lockMapClicks, sticker, angle = 2.2
|
||||
}) {
|
||||
this.angle = 2.2;
|
||||
this.angle = angle;
|
||||
this.isDragging = false;
|
||||
this.map = map;
|
||||
|
||||
|
@ -39,7 +39,7 @@ export class Sticker {
|
|||
|
||||
this.sticker = marker(latlng, { icon: mark });
|
||||
|
||||
this.setAngle(this.angle);
|
||||
this.setAngle(angle);
|
||||
|
||||
this.stickerImage.addEventListener('mousedown', this.onDragStart);
|
||||
this.stickerImage.addEventListener('mouseup', this.onDragStop);
|
||||
|
|
|
@ -19,9 +19,10 @@ export class Stickers {
|
|||
// this.createSticker({ latlng });
|
||||
// };
|
||||
|
||||
createSticker = ({ latlng, sticker }) => {
|
||||
createSticker = ({ latlng, sticker, angle = 2.2 }) => {
|
||||
const marker = new Sticker({
|
||||
latlng,
|
||||
angle,
|
||||
deleteSticker: this.deleteStickerByReference,
|
||||
map: this.map,
|
||||
lockMapClicks: this.lockMapClicks,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue