From 565f6d87b6652dbcc8e1096482053f973b29a14f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 26 Jul 2024 14:47:09 +0200 Subject: [PATCH] wip: fix editing Point coordinates by hand For now we edit ui._latlng, but in an ideal world, we should edit Point coordinates and then sync to the ui Marker. --- umap/static/umap/js/modules/data/features.js | 41 ++++++++++---------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index 0866b967..761a13f9 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -586,26 +586,27 @@ export class Point extends Feature { return ['properties._umap_options.zoomTo'] } - // appendEditFieldsets(container) { - // super.appendEditFieldsets(container) - // const coordinatesOptions = [ - // ['_latlng.lat', { handler: 'FloatInput', label: translate('Latitude') }], - // ['_latlng.lng', { handler: 'FloatInput', label: translate('Longitude') }], - // ] - // const builder = new U.FormBuilder(this, coordinatesOptions, { - // callback() { - // if (!this._latlng.isValid()) { - // Alert.error(translate('Invalid latitude or longitude')) - // builder.restoreField('_latlng.lat') - // builder.restoreField('_latlng.lng') - // } - // this.zoomTo({ easing: false }) - // }, - // callbackContext: this, - // }) - // const fieldset = DomUtil.createFieldset(container, translate('Coordinates')) - // fieldset.appendChild(builder.build()) - // } + appendEditFieldsets(container) { + super.appendEditFieldsets(container) + // FIXME edit feature geometry.coordinates instead + // (by learning FormBuilder to deal with array indexes ?) + const coordinatesOptions = [ + ['ui._latlng.lat', { handler: 'FloatInput', label: translate('Latitude') }], + ['ui._latlng.lng', { handler: 'FloatInput', label: translate('Longitude') }], + ] + const builder = new U.FormBuilder(this, coordinatesOptions, { + callback: () => { + if (!this.ui._latlng.isValid()) { + Alert.error(translate('Invalid latitude or longitude')) + builder.restoreField('ui._latlng.lat') + builder.restoreField('ui._latlng.lng') + } + this.zoomTo({ easing: false }) + } + }) + const fieldset = DomUtil.createFieldset(container, translate('Coordinates')) + fieldset.appendChild(builder.build()) + } zoomTo(event) { if (this.datalayer.isClustered() && !this._icon) {