diff --git a/backend/tools/import.js b/backend/tools/import.js index f446829..0481cc3 100755 --- a/backend/tools/import.js +++ b/backend/tools/import.js @@ -57,7 +57,7 @@ const calcPolyDistance = route => { return parseFloat(Number(summ).toFixed(2)); }; -const stickerAngleParser = angle => parseFloat((Number(angle) - Math.PI).toFixed(2)); +const stickerAngleParser = angle => parseFloat(((Number(angle) % Math.PI) + Math.PI).toFixed(2)); const stickerStyleParser = style => (REPLACEMENT[style] ? { ...REPLACEMENT[style] } diff --git a/src/index.js b/src/index.js index 6a7ec03..09c9257 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,5 @@ /* - todo fix loaded stickers has wrong text placement for right-sided captions todo save spinner todo cancelling editing someone's else map return back to it's original address /razminochnyj/ @@ -30,6 +29,7 @@ OBLIVION STARTS HERE: + done fix loaded stickers has wrong text placement for right-sided captions done fix save button should not react to clicks done stickers with empty text should not have blackbox at view mode done add ability to copy-paste address after saving diff --git a/src/modules/Sticker.js b/src/modules/Sticker.js index 6529ecc..5746de6 100644 --- a/src/modules/Sticker.js +++ b/src/modules/Sticker.js @@ -1,5 +1,4 @@ import { marker } from 'leaflet'; -// import 'leaflet-editable'; import React from 'react'; import { DomMarker } from '$utils/DomMarker'; @@ -7,6 +6,7 @@ import { STICKERS } from '$constants/stickers'; import ReactDOM from 'react-dom'; import { StickerDesc } from '$components/StickerDesc'; import classnames from 'classnames'; +import { getLabelDirection } from '$utils/geom'; export class Sticker { constructor({ @@ -14,14 +14,14 @@ export class Sticker { }) { this.text = text; this.latlng = latlng; - this.angle = angle; + this.angle = parseFloat(((angle && (angle % Math.PI)) || 2.2).toFixed(2)); this.isDragging = false; this.map = map; this.sticker = sticker; this.set = set; this.editable = true; this.triggerOnChange = triggerOnChange; - this.direction = 'right'; + this.direction = getLabelDirection(this.angle); this.deleteSticker = deleteSticker; this.lockMapClicks = lockMapClicks; @@ -33,7 +33,7 @@ export class Sticker { ref={el => { this.stickerArrow = el; }} />