From e4bcb53c6f66d0bc02f03caf1411f3027b3e381a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 8 May 2024 15:16:33 +0200 Subject: [PATCH] feat(sync): Sync only when the edition of a feature is over. It's less spectacular than sending the position as it changes, but takes less bandwidth and seems good enough. --- umap/static/umap/js/umap.controls.js | 5 ----- umap/static/umap/js/umap.features.js | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 28c7b288..b8461ef2 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1261,16 +1261,11 @@ U.Editable = L.Editable.extend({ this.on('editable:drawing:cancel', (e) => { console.log('editable:drawing:cancel') if (e.layer instanceof U.Marker) e.layer.del() - else { - // the user might just exit with escape - e.layer.onCommit() - } }) this.on('editable:drawing:commit', function (e) { console.log('editable:drawing:commit') e.layer.isDirty = true if (this.map.editedFeature !== e.layer) e.layer.edit(e) - e.layer.onCommit() }) this.on('editable:editing', (e) => { console.log('editable:editing') diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index a7329c03..e8834a2a 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -652,6 +652,7 @@ U.Marker = L.Marker.extend({ }, this ) + this.on('editable:drawing:end', this.onCommit) if (!this.isReadOnly()) this.on('mouseover', this._enableDragging) this.on('mouseout', this._onMouseOut) this._popupHandlersAdded = true // prevent Leaflet from binding event on bindPopup @@ -933,6 +934,7 @@ U.PathMixin = { addInteractions: function () { U.FeatureMixin.addInteractions.call(this) + this.on('editable:disable', this.onCommit) this.on('mouseover', this._onMouseOver) this.on('edit', this.makeDirty) this.on('drag editable:drag', this._onDrag) @@ -942,7 +944,6 @@ U.PathMixin = { _onDrag: function () { if (this._tooltip) this._tooltip.setLatLng(this.getCenter()) - this.syncUpdatedProperties(['latlng']) }, transferShape: function (at, to) {