mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
chore: switch to an UI class getter
This commit is contained in:
parent
00c384bf25
commit
7863cebc32
1 changed files with 11 additions and 16 deletions
|
@ -114,8 +114,7 @@ class Feature {
|
|||
}
|
||||
|
||||
makeUI() {
|
||||
const klass = this.getUIClass()
|
||||
this._ui = new klass(this, this.toLatLngs())
|
||||
this._ui = new this.uiClass(this, this.toLatLngs())
|
||||
}
|
||||
|
||||
getClassName() {
|
||||
|
@ -569,7 +568,7 @@ class Feature {
|
|||
|
||||
redraw() {
|
||||
if (this.datalayer?.isVisible()) {
|
||||
if (this.getUIClass() !== this.ui.getClass()) {
|
||||
if (this.uiClass !== this.ui.getClass()) {
|
||||
this.datalayer.hideFeature(this)
|
||||
this.makeUI()
|
||||
this.datalayer.showFeature(this)
|
||||
|
@ -581,6 +580,8 @@ class Feature {
|
|||
}
|
||||
|
||||
export class Point extends Feature {
|
||||
uiClass = LeafletMarker
|
||||
|
||||
constructor(datalayer, geojson, id) {
|
||||
super(datalayer, geojson, id)
|
||||
this.staticOptions = {
|
||||
|
@ -597,10 +598,6 @@ export class Point extends Feature {
|
|||
return { coordinates: GeoJSON.latLngToCoords(latlng), type: 'Point' }
|
||||
}
|
||||
|
||||
getUIClass() {
|
||||
return LeafletMarker
|
||||
}
|
||||
|
||||
hasGeom() {
|
||||
return Boolean(this.coordinates)
|
||||
}
|
||||
|
@ -787,6 +784,8 @@ class Path extends Feature {
|
|||
}
|
||||
|
||||
export class LineString extends Path {
|
||||
uiClass = LeafletPolyline
|
||||
|
||||
constructor(datalayer, geojson, id) {
|
||||
super(datalayer, geojson, id)
|
||||
this.staticOptions = {
|
||||
|
@ -816,10 +815,6 @@ export class LineString extends Path {
|
|||
return !this.coordinates.length
|
||||
}
|
||||
|
||||
getUIClass() {
|
||||
return LeafletPolyline
|
||||
}
|
||||
|
||||
isSameClass(other) {
|
||||
return other instanceof LineString
|
||||
}
|
||||
|
@ -913,6 +908,11 @@ export class Polygon extends Path {
|
|||
}
|
||||
}
|
||||
|
||||
get uiClass() {
|
||||
if (this.getOption('mask')) return MaskPolygon
|
||||
return LeafletPolygon
|
||||
}
|
||||
|
||||
toLatLngs() {
|
||||
return GeoJSON.coordsToLatLngs(this.coordinates, this.type === 'Polygon' ? 1 : 2)
|
||||
}
|
||||
|
@ -933,11 +933,6 @@ export class Polygon extends Path {
|
|||
return !this.coordinates.length || !this.coordinates[0].length
|
||||
}
|
||||
|
||||
getUIClass() {
|
||||
if (this.getOption('mask')) return MaskPolygon
|
||||
return LeafletPolygon
|
||||
}
|
||||
|
||||
isSameClass(other) {
|
||||
return other instanceof Polygon
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue