Ongoing cleanup and refactoring of maps.

This commit is contained in:
2019-11-25 18:04:11 +01:00
parent 88048f14ec
commit 5305561619
16 changed files with 462 additions and 158 deletions
+20 -6
View File
@@ -86,7 +86,6 @@ export class GeoLayer {
set visibility(value) {
let { min = 0, max = Infinity } = value
console.log(min)
this._visibility = { min, max }
}
@@ -224,9 +223,11 @@ export class MapLayer extends GeoLayer {
mapList,
scatterContainer,
displayObject,
{ onTransform = null, onChange = null, focus = null, zoom = null, viewport = null } = {}
{ onTransform = null, onChange = null, focus = null, zoom = null, viewport = null, name = null } = {}
) {
super(displayObject)
super(displayObject, {
name
})
this.transformHandler = new EventHandler('onTransform', {
listeners: onTransform
@@ -292,6 +293,17 @@ export class MapLayer extends GeoLayer {
return mapLayerClone
}
/**
* Helper function to quickly display the next map.
* Order is defined by the key ordering of the maplist.
*
* @memberof MapLayer
*/
next() {
let nextMap = this.mapList.next()
this.changeMap(nextMap)
}
/**
* Changes the map to the specified one, keeping the position and the zoom of the old map.
*
@@ -304,7 +316,7 @@ export class MapLayer extends GeoLayer {
/* map ,
useScatterAsContainer = true // If set to false, the normal container is used. This is necessary when using submaps and the container need to be a RigidContainer.*/
) {
console.log('Change map to: ', name)
console.log('🗺️ Change map to: ', name)
let oldMap = this.map
this.mapList.select(name)
@@ -316,10 +328,8 @@ export class MapLayer extends GeoLayer {
let map = this.map
if (map) {
console.log('Load Map')
map.load()
console.log(this, this.scatterContainer)
this.scatterContainer.addChild(map.image)
this.mapview.apply(map)
@@ -403,6 +413,10 @@ export class MapLayer extends GeoLayer {
get mapLayer() {
return this
}
cleanup() {
this.mapList.cleanup()
}
}
MapLayer.idx = 0