Added functionality and dark mode to doctests. And other changes in maps.

This commit is contained in:
2019-11-20 15:59:10 +01:00
parent 89395ba641
commit 6dcf6d38da
13 changed files with 8261 additions and 8520 deletions
+48 -24
View File
@@ -145,6 +145,19 @@ export class GeoLayer {
} else console.warn('Tried to remove layer that was not set.', this, layer)
}
remove(graphics) {
if (graphics instanceof GeoGraphics) {
let index = this.geographics.indexOf(geographics)
if (index != -1) {
this.displayObject.removeChild(geographics)
} else {
console.error('Could not remove geographics from geolayer.', this, geographics)
}
} else {
this.displayObject.removeChild(graphics)
}
}
set parent(parent) {
this._parent = parent
}
@@ -208,9 +221,10 @@ export class GeoLayer {
export class MapLayer extends GeoLayer {
constructor(
mapList,
scatterContainer,
displayObject,
{ onTransform = null, onChange = null, focus = null, zoom = null, viewport = null, mapList = null } = {}
{ onTransform = null, onChange = null, focus = null, zoom = null, viewport = null } = {}
) {
super(displayObject)
@@ -231,12 +245,16 @@ export class MapLayer extends GeoLayer {
})
this.mapList = mapList
this._map = null
// //TODO Implement error handling here.
// this.maps = maps
// if (opts.map) this.placeMap(opts.map)
this.dynamicElements = new Map()
// Binds the transformed callback beforehand.
this.transformed = this.transformed.bind(this)
this.changeMap(mapList.active)
}
adapt() {
@@ -258,21 +276,18 @@ export class MapLayer extends GeoLayer {
this.transformHandler.call(this)
}
clone(container = null) {
let clone = {}
for (let name of Object.keys(this.maps)) {
//console.info(this.maps[name])
clone[name] = this.maps[name].clone(container)
}
clone(scatterContainer, container = null) {
let mapList = this.mapList.clone()
container = container == null ? new PIXI.Container() : container
//console.info(this.active)
let mapLayerClone = new MapLayer(this.active, clone, container, {
let mapLayerClone = new MapLayer(mapList, scatterContainer, container, {
name: MapLayer.idx++,
viewport: this.mapview.viewport,
focus: this.mapview.focus,
zoom: this.mapview.zoom
zoom: this.mapview.zoom,
mapList
})
//mapLayerClone._map = clone['luftbild']
mapLayerClone.childrenVisibility = this.childrenVisibility
return mapLayerClone
}
@@ -285,20 +300,29 @@ export class MapLayer extends GeoLayer {
* @memberof MapLayer
*/
changeMap(
map /*,
name
/* 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.*/
) {
if (map instanceof GeoMap) {
console.log('Change map to: ', map)
let oldMap = this.map
if (oldMap) oldMap.unload()
console.log('Change map to: ', name)
let oldMap = this.map
this._map = map
this.mapList.select(name)
this.map.load()
this.scatterContainer.addChild(this.map.image)
if (oldMap) {
oldMap.unload()
oldMap.onTransform.remove(this.transformed)
}
this.mapview.apply(this.map)
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)
map.image.addChild(this.displayObject)
// A geolayer's displayObject is on the parent layer.
@@ -309,9 +333,9 @@ export class MapLayer extends GeoLayer {
//Call transform one time manually.
this.transformed()
this.map.onTransform.add(this.transformed.bind(this))
map.onTransform.add(this.transformed)
} else {
console.error("Could not set map, it's not of type GeoMap.", map)
console.error(`Could not change map to ${name}.`)
}
/*Logging.log(`Map change: ${key}`)
@@ -368,7 +392,7 @@ export class MapLayer extends GeoLayer {
}
get map() {
return this._map
return this.mapList.map
}
/**