mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
router now properly handles poly changes
This commit is contained in:
parent
e477f50283
commit
245b559e2d
3 changed files with 40 additions and 4 deletions
|
@ -3,24 +3,28 @@ import L from "leaflet";
|
|||
const polyStyle = { color: '#ff3333', weight: '5' };
|
||||
|
||||
export class Poly {
|
||||
constructor({ map }) {
|
||||
constructor({ map, routerMoveStart }) {
|
||||
this.poly = L.polyline([], polyStyle);
|
||||
this.latlngs = [];
|
||||
this.poly.addTo(map);
|
||||
this.map = map;
|
||||
|
||||
this.routerMoveStart = routerMoveStart;
|
||||
this.bindEvents();
|
||||
}
|
||||
|
||||
updateMarks = () => {
|
||||
const coords = this.poly.toGeoJSON().geometry.coordinates;
|
||||
this.latlngs = (coords && coords.length && coords.map(([lng, lat]) => ({ lng, lat }))) || [];
|
||||
|
||||
this.routerMoveStart();
|
||||
};
|
||||
|
||||
bindEvents = () => {
|
||||
// Если на карте что-то меняется, пересчитать километражи
|
||||
this.map.editTools.addEventListener('editable:drawing:mouseup', this.updateMarks);
|
||||
this.map.editTools.addEventListener('editable:vertex:dragend', this.updateMarks);
|
||||
this.map.editTools.addEventListener('editable:vertex:mouseup', this.updateMarks);
|
||||
this.map.editTools.addEventListener('editable:vertex:deleted', this.updateMarks);
|
||||
this.map.editTools.addEventListener('editable:vertex:new', this.updateMarks);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue