From bb661b976be7d9d6172609157db52958ffd1acda Mon Sep 17 00:00:00 2001 From: muerwre Date: Thu, 7 Feb 2019 16:42:38 +0700 Subject: [PATCH] fixed middle markers stay on marker deletion --- .../{MapListMoreDialog.jsx => MapListDialog.jsx} | 2 +- src/containers/LeftDialog.jsx | 4 ++-- src/index.js | 3 ++- src/modules/Map.js | 1 - src/utils/EditablePolyline.js | 11 ++++++----- 5 files changed, 11 insertions(+), 10 deletions(-) rename src/components/dialogs/{MapListMoreDialog.jsx => MapListDialog.jsx} (97%) diff --git a/src/components/dialogs/MapListMoreDialog.jsx b/src/components/dialogs/MapListDialog.jsx similarity index 97% rename from src/components/dialogs/MapListMoreDialog.jsx rename to src/components/dialogs/MapListDialog.jsx index 0f99512..d0cb452 100644 --- a/src/components/dialogs/MapListMoreDialog.jsx +++ b/src/components/dialogs/MapListDialog.jsx @@ -175,4 +175,4 @@ const mapDispatchToProps = dispatch => bindActionCreators({ setDialogActive, }, dispatch); -export const MapListMoreDialog = connect(mapStateToProps, mapDispatchToProps)(Component); +export const MapListDialog = connect(mapStateToProps, mapDispatchToProps)(Component); diff --git a/src/containers/LeftDialog.jsx b/src/containers/LeftDialog.jsx index a41857a..3bd3ef0 100644 --- a/src/containers/LeftDialog.jsx +++ b/src/containers/LeftDialog.jsx @@ -4,7 +4,7 @@ import { DIALOGS } from '$constants/dialogs'; import classnames from 'classnames'; import { AppInfoDialog } from '$components/dialogs/AppInfoDialog'; import { Icon } from '$components/panels/Icon'; -import { MapListMoreDialog } from '$components/dialogs/MapListMoreDialog'; +import { MapListDialog } from '$components/dialogs/MapListDialog'; type Props = { dialog: String, @@ -14,7 +14,7 @@ type Props = { } const LEFT_DIALOGS = { - [DIALOGS.MAP_LIST]: MapListMoreDialog, + [DIALOGS.MAP_LIST]: MapListDialog, [DIALOGS.APP_INFO]: AppInfoDialog, }; diff --git a/src/index.js b/src/index.js index 6057373..b9b4781 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,8 @@ ## BUGS - todo cancelling editing someone's else map return back to it's original address /razminochnyj/ + todo adding/removing points doesn't change distance + done cancelling editing someone's else map return back to it's original address /razminochnyj/ todo selecting logo on crop todo delete sticker icon todo fix arrows (can't reproduce now :-( ) diff --git a/src/modules/Map.js b/src/modules/Map.js index c2e850f..305a1e7 100644 --- a/src/modules/Map.js +++ b/src/modules/Map.js @@ -1,6 +1,5 @@ import { map, tileLayer } from 'leaflet'; import 'leaflet/dist/leaflet.css'; -// import 'leaflet-editable'; import { PROVIDER } from '$config/frontend'; import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers'; diff --git a/src/utils/EditablePolyline.js b/src/utils/EditablePolyline.js index 27827ca..f21dfb0 100644 --- a/src/utils/EditablePolyline.js +++ b/src/utils/EditablePolyline.js @@ -435,13 +435,14 @@ L.Polyline.polylineEditor = L.Polyline.extend({ if (!this._markers || this._markers.length <= 2) return; if (this.constr.is_drawing) return; + if (_marker.newPointMarker) { + this._map.removeLayer(_marker.newPointMarker); + } this._map.removeLayer(_marker); - // that._map.removeLayer(newPointMarker); - this._markers.splice(_pointNo, 1); this._reloadPolyline(_pointNo); - if (this._options.onPointAdded) this._options.onPointAdded(event, 'dropped'); + if (this._options.onPointDropped) this._options.onPointDropped(event, 'dropped'); }); // marker.on(that._options.addFirstLastPointEvent, (event) => { @@ -583,8 +584,6 @@ L.Polyline.polylineEditor = L.Polyline.extend({ return; } - if (this._options.onPointAdded) this._options.onPointAdded(event); - const pointNo = (this._markers && this._markers.length) || 0; this._addMarkers(pointNo, event.latlng, true); @@ -592,6 +591,8 @@ L.Polyline.polylineEditor = L.Polyline.extend({ this._map.off('click', this._addPointForward); + if (this._options.onPointAdded) this._options.onPointAdded(event); + setTimeout(this._prepareForNewPoint.bind(this), 25); };