diff --git a/src/modules/Editor.js b/src/modules/Editor.js index 2c882c5..ce34bd4 100644 --- a/src/modules/Editor.js +++ b/src/modules/Editor.js @@ -220,11 +220,14 @@ export class Editor { if (owner) this.owner = owner; - if (!route || route.length <= 1) return; + // if (!route || route.length <= 1) return; + }; + + fitDrawing = () => { + if (this.poly.isEmpty()) return; const bounds = this.poly.poly.getBounds(); - - if (route && bounds && Object.values(bounds)) this.map.map.fitBounds(bounds); + if (bounds && Object.values(bounds)) this.map.map.fitBounds(bounds); }; setInitialData = () => { diff --git a/src/modules/Poly.js b/src/modules/Poly.js index bec868e..4bd21db 100644 --- a/src/modules/Poly.js +++ b/src/modules/Poly.js @@ -159,4 +159,6 @@ export class Poly { clearArrows = () => this.arrows.clearLayers(); dumpData = () => this.latlngs; + + isEmpty = () => !this.latlngs || Object.values(this.latlngs).length < 0; } diff --git a/src/redux/user/sagas.js b/src/redux/user/sagas.js index edb0468..6a90173 100644 --- a/src/redux/user/sagas.js +++ b/src/redux/user/sagas.js @@ -66,6 +66,7 @@ function* mapInitSaga() { if (map) { yield editor.setData(map); + yield editor.fitDrawing(); yield put(setChanged(false)); if (mode && mode === 'edit') {