mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
new-poly: it works (without dump)
This commit is contained in:
parent
fbf4c06370
commit
bb5b5e5ad5
3 changed files with 87 additions and 54 deletions
|
@ -38,13 +38,13 @@ export class Editor {
|
|||
map: { map }
|
||||
} = this;
|
||||
|
||||
this.poly = new Poly({
|
||||
this.poly = new NewPoly({
|
||||
map, routerMoveStart, lockMapClicks, setTotalDist: this.setDistance, triggerOnChange, editor: this,
|
||||
});
|
||||
|
||||
this.newPoly = new NewPoly({
|
||||
map, editor: this,
|
||||
});
|
||||
// this.newPoly = new NewPoly({
|
||||
// map, editor: this,
|
||||
// });
|
||||
|
||||
this.stickers = new Stickers({ map, lockMapClicks, triggerOnChange });
|
||||
this.router = new Router({
|
||||
|
|
|
@ -25,18 +25,17 @@ export class NewPoly {
|
|||
// { lat: 55.0145, lng: 82.67699 },
|
||||
];
|
||||
|
||||
const customPointListeners = {
|
||||
mousedown: console.log,
|
||||
mouseup: console.log,
|
||||
dragstart: console.log,
|
||||
dragend: console.log,
|
||||
};
|
||||
|
||||
this.poly = L.Polyline.PolylineEditor(coordinates, {
|
||||
...polyStyle,
|
||||
maxMarkers: 300,
|
||||
customPointListeners,
|
||||
customNewPointListenets: customPointListeners,
|
||||
maxMarkers: 50,
|
||||
|
||||
onPointsSet: this.updateMarks,
|
||||
onMarkerDragEnd: this.updateMarks,
|
||||
onPointAdded: this.updateMarks,
|
||||
onPointDropped: this.updateMarks,
|
||||
|
||||
onMarkersHide: () => console.log('all markers are hidden'),
|
||||
onMarkersShow: () => console.log('all markers are visible'),
|
||||
}).addTo(map);
|
||||
|
||||
this.latlngs = [];
|
||||
|
@ -82,9 +81,11 @@ export class NewPoly {
|
|||
});
|
||||
};
|
||||
|
||||
updateMarks = () => {
|
||||
return;
|
||||
updateMarks = (e) => {
|
||||
// console.log('upd', e);
|
||||
// return;
|
||||
const coords = this.poly.toGeoJSON().geometry.coordinates;
|
||||
|
||||
this.latlngs = (coords && coords.length && coords.map(([lng, lat]) => ({ lng, lat }))) || [];
|
||||
const meters = (this.poly && (L.GeometryUtil.length(this.poly) / 1000)) || 0;
|
||||
const kilometers = (meters && meters.toFixed(1)) || 0;
|
||||
|
@ -92,7 +93,7 @@ export class NewPoly {
|
|||
this.setTotalDist(kilometers);
|
||||
this.routerMoveStart();
|
||||
|
||||
// this.drawArrows(); // <-- uncomment
|
||||
this.drawArrows(); // <-- uncomment
|
||||
|
||||
if (coords.length > 1) this.triggerOnChange();
|
||||
};
|
||||
|
@ -144,7 +145,7 @@ export class NewPoly {
|
|||
};
|
||||
|
||||
continue = () => {
|
||||
this.poly.continueForwards();
|
||||
this.poly.editor.continueForward();
|
||||
// if (this.latlngs && this.latlngs.length) {
|
||||
// // this.poly.enableEdit().continueForward();
|
||||
// // this.poly.editor.reset();
|
||||
|
@ -156,7 +157,7 @@ export class NewPoly {
|
|||
};
|
||||
|
||||
stop = () => {
|
||||
if (this.poly) this.poly.stopDrawing();
|
||||
if (this.poly) this.poly.editor.stopDrawing();
|
||||
};
|
||||
|
||||
continueForward = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue