From 630ed4352550cedc3a1e90b35eaf54a318bc59e5 Mon Sep 17 00:00:00 2001 From: muerwre Date: Thu, 20 Dec 2018 18:43:31 +0700 Subject: [PATCH] new-poly: it works (with dump) --- src/modules/NewPoly.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/NewPoly.js b/src/modules/NewPoly.js index 7a9da6d..4d1a58a 100644 --- a/src/modules/NewPoly.js +++ b/src/modules/NewPoly.js @@ -38,7 +38,6 @@ export class NewPoly { onMarkersShow: () => console.log('all markers are visible'), }).addTo(map); - this.latlngs = []; this.poly.addTo(map); this.poly._reloadPolyline(); this.editor = editor; @@ -86,7 +85,7 @@ export class NewPoly { // return; const coords = this.poly.toGeoJSON().geometry.coordinates; - this.latlngs = (coords && coords.length && coords.map(([lng, lat]) => ({ lng, lat }))) || []; + // 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; @@ -200,6 +199,13 @@ export class NewPoly { dumpData = () => this.latlngs; + get latlngs() { + return ( + this.poly && this.poly.getLatLngs().length + && this.poly.getLatLngs().map(el => ({ ...el }))) || []; + + } + get isEmpty() { return (!this.latlngs || Object.values(this.latlngs).length <= 0); }