mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
Merge pull request #2102 from umap-project/edit-circlemarker-properties
fix: do not fail when trying to edit a circlemarker
This commit is contained in:
commit
ff014429b9
2 changed files with 23 additions and 13 deletions
|
@ -98,6 +98,10 @@ class Feature {
|
||||||
this.pushGeometry()
|
this.pushGeometry()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isOnScreen() {
|
||||||
|
return this.ui?.isOnScreen()
|
||||||
|
}
|
||||||
|
|
||||||
pushGeometry() {
|
pushGeometry() {
|
||||||
this.ui.setLatLngs(this.toLatLngs())
|
this.ui.setLatLngs(this.toLatLngs())
|
||||||
}
|
}
|
||||||
|
@ -257,7 +261,7 @@ class Feature {
|
||||||
builder.helpers['properties.name'].input.focus()
|
builder.helpers['properties.name'].input.focus()
|
||||||
})
|
})
|
||||||
this.map.editedFeature = this
|
this.map.editedFeature = this
|
||||||
if (!this.isOnScreen()) this.zoomTo(event)
|
if (!this.ui.isOnScreen()) this.zoomTo(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAdvancedEditActions(container) {
|
getAdvancedEditActions(container) {
|
||||||
|
@ -661,11 +665,6 @@ export class Point extends Feature {
|
||||||
super.zoomTo(event)
|
super.zoomTo(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isOnScreen(bounds) {
|
|
||||||
bounds = bounds || this.map.getBounds()
|
|
||||||
return bounds.contains(this.toLatLngs())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Path extends Feature {
|
class Path extends Feature {
|
||||||
|
@ -753,11 +752,6 @@ class Path extends Feature {
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
isOnScreen(bounds) {
|
|
||||||
bounds = bounds || this.map.getBounds()
|
|
||||||
return bounds.overlaps(this.bounds)
|
|
||||||
}
|
|
||||||
|
|
||||||
zoomTo({ easing, callback }) {
|
zoomTo({ easing, callback }) {
|
||||||
// Use bounds instead of centroid for paths.
|
// Use bounds instead of centroid for paths.
|
||||||
easing = easing || this.map.getOption('easing')
|
easing = easing || this.map.getOption('easing')
|
||||||
|
|
|
@ -146,9 +146,16 @@ const FeatureMixin = {
|
||||||
getPopupToolbarAnchor: () => [0, 0],
|
getPopupToolbarAnchor: () => [0, 0],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PointMixin = {
|
||||||
|
isOnScreen: function (bounds) {
|
||||||
|
bounds = bounds || this._map.getBounds()
|
||||||
|
return bounds.contains(this.getCenter())
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export const LeafletMarker = Marker.extend({
|
export const LeafletMarker = Marker.extend({
|
||||||
parentClass: Marker,
|
parentClass: Marker,
|
||||||
includes: [FeatureMixin],
|
includes: [FeatureMixin, PointMixin],
|
||||||
|
|
||||||
initialize: function (feature, latlng) {
|
initialize: function (feature, latlng) {
|
||||||
FeatureMixin.initialize.call(this, feature, latlng)
|
FeatureMixin.initialize.call(this, feature, latlng)
|
||||||
|
@ -411,6 +418,11 @@ const PathMixin = {
|
||||||
'dashArray',
|
'dashArray',
|
||||||
'interactive',
|
'interactive',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
isOnScreen: function (bounds) {
|
||||||
|
bounds = bounds || this._map.getBounds()
|
||||||
|
return bounds.overlaps(this.getBounds())
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LeafletPolyline = Polyline.extend({
|
export const LeafletPolyline = Polyline.extend({
|
||||||
|
@ -552,7 +564,7 @@ export const MaskPolygon = LeafletPolygon.extend({
|
||||||
|
|
||||||
export const CircleMarker = BaseCircleMarker.extend({
|
export const CircleMarker = BaseCircleMarker.extend({
|
||||||
parentClass: BaseCircleMarker,
|
parentClass: BaseCircleMarker,
|
||||||
includes: [FeatureMixin, PathMixin],
|
includes: [FeatureMixin, PathMixin, PointMixin],
|
||||||
initialize: function (feature, latlng) {
|
initialize: function (feature, latlng) {
|
||||||
if (Array.isArray(latlng) && !(latlng[0] instanceof Number)) {
|
if (Array.isArray(latlng) && !(latlng[0] instanceof Number)) {
|
||||||
// Must be a line or polygon
|
// Must be a line or polygon
|
||||||
|
@ -570,4 +582,8 @@ export const CircleMarker = BaseCircleMarker.extend({
|
||||||
getCenter: function () {
|
getCenter: function () {
|
||||||
return this._latlng
|
return this._latlng
|
||||||
},
|
},
|
||||||
|
// FIXME when Leaflet.Editable knows about CircleMarker
|
||||||
|
editEnabled: () => false,
|
||||||
|
enableEdit: () => {}, // No-op
|
||||||
|
disableEdit: () => {}, // No-op
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue