mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 03:42:37 +02:00
fix(sync): Allow cloning of features
Removing the `id` from the feature when cloning makes it generate a new one. Without this change, the cloned feature keep the already existing `id`, and during sync, the original object is lost (replaced by the clone). Nobody wants to be replaced by a clone.
This commit is contained in:
parent
e4bcb53c6f
commit
28a359e03f
1 changed files with 7 additions and 2 deletions
|
@ -595,7 +595,10 @@ U.FeatureMixin = {
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function () {
|
clone: function () {
|
||||||
const layer = this.datalayer.geojsonToFeatures(this.toGeoJSON())
|
const geoJSON = this.toGeoJSON()
|
||||||
|
delete geoJSON.id
|
||||||
|
delete geoJSON.properties.id
|
||||||
|
const layer = this.datalayer.geojsonToFeatures(geoJSON)
|
||||||
layer.isDirty = true
|
layer.isDirty = true
|
||||||
layer.edit()
|
layer.edit()
|
||||||
return layer
|
return layer
|
||||||
|
@ -652,7 +655,7 @@ U.Marker = L.Marker.extend({
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
this.on('editable:drawing:end', this.onCommit)
|
this.on('editable:drawing:commit', this.onCommit)
|
||||||
if (!this.isReadOnly()) this.on('mouseover', this._enableDragging)
|
if (!this.isReadOnly()) this.on('mouseover', this._enableDragging)
|
||||||
this.on('mouseout', this._onMouseOut)
|
this.on('mouseout', this._onMouseOut)
|
||||||
this._popupHandlersAdded = true // prevent Leaflet from binding event on bindPopup
|
this._popupHandlersAdded = true // prevent Leaflet from binding event on bindPopup
|
||||||
|
@ -1275,6 +1278,8 @@ U.Polygon = L.Polygon.extend({
|
||||||
|
|
||||||
toPolyline: function () {
|
toPolyline: function () {
|
||||||
const geojson = this.toGeoJSON()
|
const geojson = this.toGeoJSON()
|
||||||
|
delete geojson.id
|
||||||
|
delete geojson.properties.id
|
||||||
geojson.geometry.type = 'LineString'
|
geojson.geometry.type = 'LineString'
|
||||||
geojson.geometry.coordinates = U.Utils.flattenCoordinates(
|
geojson.geometry.coordinates = U.Utils.flattenCoordinates(
|
||||||
geojson.geometry.coordinates
|
geojson.geometry.coordinates
|
||||||
|
|
Loading…
Reference in a new issue