Revert "chore: switch to an UI class getter"

This reverts commit 6b793758c5d7d85a2120a5376134f485ea0807bc.
This commit is contained in:
Yohan Boniface 2024-08-07 10:00:50 +02:00
parent 7863cebc32
commit 327c1603f5

View file

@ -114,7 +114,8 @@ class Feature {
} }
makeUI() { makeUI() {
this._ui = new this.uiClass(this, this.toLatLngs()) const klass = this.getUIClass()
this._ui = new klass(this, this.toLatLngs())
} }
getClassName() { getClassName() {
@ -568,7 +569,7 @@ class Feature {
redraw() { redraw() {
if (this.datalayer?.isVisible()) { if (this.datalayer?.isVisible()) {
if (this.uiClass !== this.ui.getClass()) { if (this.getUIClass() !== this.ui.getClass()) {
this.datalayer.hideFeature(this) this.datalayer.hideFeature(this)
this.makeUI() this.makeUI()
this.datalayer.showFeature(this) this.datalayer.showFeature(this)
@ -580,8 +581,6 @@ class Feature {
} }
export class Point extends Feature { export class Point extends Feature {
uiClass = LeafletMarker
constructor(datalayer, geojson, id) { constructor(datalayer, geojson, id) {
super(datalayer, geojson, id) super(datalayer, geojson, id)
this.staticOptions = { this.staticOptions = {
@ -598,6 +597,10 @@ export class Point extends Feature {
return { coordinates: GeoJSON.latLngToCoords(latlng), type: 'Point' } return { coordinates: GeoJSON.latLngToCoords(latlng), type: 'Point' }
} }
getUIClass() {
return LeafletMarker
}
hasGeom() { hasGeom() {
return Boolean(this.coordinates) return Boolean(this.coordinates)
} }
@ -784,8 +787,6 @@ class Path extends Feature {
} }
export class LineString extends Path { export class LineString extends Path {
uiClass = LeafletPolyline
constructor(datalayer, geojson, id) { constructor(datalayer, geojson, id) {
super(datalayer, geojson, id) super(datalayer, geojson, id)
this.staticOptions = { this.staticOptions = {
@ -815,6 +816,10 @@ export class LineString extends Path {
return !this.coordinates.length return !this.coordinates.length
} }
getUIClass() {
return LeafletPolyline
}
isSameClass(other) { isSameClass(other) {
return other instanceof LineString return other instanceof LineString
} }
@ -908,11 +913,6 @@ export class Polygon extends Path {
} }
} }
get uiClass() {
if (this.getOption('mask')) return MaskPolygon
return LeafletPolygon
}
toLatLngs() { toLatLngs() {
return GeoJSON.coordsToLatLngs(this.coordinates, this.type === 'Polygon' ? 1 : 2) return GeoJSON.coordsToLatLngs(this.coordinates, this.type === 'Polygon' ? 1 : 2)
} }
@ -933,6 +933,11 @@ export class Polygon extends Path {
return !this.coordinates.length || !this.coordinates[0].length return !this.coordinates.length || !this.coordinates[0].length
} }
getUIClass() {
if (this.getOption('mask')) return MaskPolygon
return LeafletPolygon
}
isSameClass(other) { isSameClass(other) {
return other instanceof Polygon return other instanceof Polygon
} }