Merge pull request #2107 from umap-project/visible-vertexmarkers

wip: only show visible vertexmarkers and do not show when there are too much
This commit is contained in:
Yohan Boniface 2024-09-06 17:21:03 +02:00 committed by GitHub
commit ae09c343d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 2114 additions and 1929 deletions

14
package-lock.json generated
View file

@ -19,7 +19,7 @@
"jsdom": "^24.0.0",
"leaflet": "1.9.4",
"leaflet-contextmenu": "^1.4.0",
"leaflet-editable": "^1.2.0",
"leaflet-editable": "^1.3.0",
"leaflet-editinosm": "0.2.3",
"leaflet-formbuilder": "0.2.10",
"leaflet-fullscreen": "1.0.2",
@ -3015,9 +3015,9 @@
"integrity": "sha1-4r2kga8QJggOq6oymX5TH9RPYFw="
},
"node_modules/leaflet-editable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/leaflet-editable/-/leaflet-editable-1.2.0.tgz",
"integrity": "sha512-wG11JwpL8zqIbypTop6xCRGagMuWw68ihYu4uqrqc5Ep0wnEJeyob7NB2Rt5t74Oih4rwJ3OfwaGbzdowOGfYQ=="
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/leaflet-editable/-/leaflet-editable-1.3.0.tgz",
"integrity": "sha512-elXuUM6L3kjZsg3P6PV7SEYNBX0iDT3oG1vWVnfm5Axd2q8cUqDPQYkru++m7/bE4jL07OKeETdHE543K6zsbQ=="
},
"node_modules/leaflet-editinosm": {
"version": "0.2.3",
@ -7154,9 +7154,9 @@
"integrity": "sha1-4r2kga8QJggOq6oymX5TH9RPYFw="
},
"leaflet-editable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/leaflet-editable/-/leaflet-editable-1.2.0.tgz",
"integrity": "sha512-wG11JwpL8zqIbypTop6xCRGagMuWw68ihYu4uqrqc5Ep0wnEJeyob7NB2Rt5t74Oih4rwJ3OfwaGbzdowOGfYQ=="
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/leaflet-editable/-/leaflet-editable-1.3.0.tgz",
"integrity": "sha512-elXuUM6L3kjZsg3P6PV7SEYNBX0iDT3oG1vWVnfm5Axd2q8cUqDPQYkru++m7/bE4jL07OKeETdHE543K6zsbQ=="
},
"leaflet-editinosm": {
"version": "0.2.3",

View file

@ -47,7 +47,7 @@
"jsdom": "^24.0.0",
"leaflet": "1.9.4",
"leaflet-contextmenu": "^1.4.0",
"leaflet-editable": "^1.2.0",
"leaflet-editable": "^1.3.0",
"leaflet-editinosm": "0.2.3",
"leaflet-formbuilder": "0.2.10",
"leaflet-fullscreen": "1.0.2",

View file

@ -680,8 +680,8 @@ class Path extends Feature {
edit(event) {
if (this.map.editEnabled) {
if (!this.ui.editEnabled()) this.ui.enableEdit()
super.edit(event)
if (!this.ui.editEnabled()) this.ui.makeGeometryEditable()
}
}

View file

@ -288,6 +288,21 @@ const PathMixin = {
}
},
makeGeometryEditable: function () {
if (this._map.editedFeature !== this.feature) {
this.disableEdit()
return
}
this._map.once('moveend', this.makeGeometryEditable, this)
const pointsCount = this._parts.reduce((acc, part) => acc + part.length, 0)
if (pointsCount > 100 && this._map.getZoom() < this._map.getMaxZoom()) {
this._map.tooltip.open({ content: L._('Please zoom in to edit the geometry') })
this.disableEdit()
} else {
this.enableEdit()
}
},
addInteractions: function () {
FeatureMixin.addInteractions.call(this)
this.on('editable:disable', this.onCommit)
@ -383,7 +398,7 @@ const PathMixin = {
getContextMenuEditItems: function (event) {
const items = FeatureMixin.getContextMenuEditItems.call(this, event)
if (
this._map?.editedFeature !== this &&
this._map?.editedFeature !== this.feature &&
this.feature.isSameClass(this._map.editedFeature)
) {
items.push({

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long