Fixed map doctest.
This commit is contained in:
+2
-75
@@ -130,11 +130,8 @@ export class GeoMap {
|
||||
}
|
||||
|
||||
unload() {
|
||||
console.log('unload', this, this.image)
|
||||
if (this.image) {
|
||||
console.log('removeScatter')
|
||||
if (this.image.parent) {
|
||||
console.log('Remove from parent')
|
||||
this.image.parent.removeChild(this.image)
|
||||
}
|
||||
this.image.scatter = null
|
||||
@@ -383,6 +380,7 @@ export class GeoMap {
|
||||
if (GeoMap._validateJson(json, error)) {
|
||||
for (let [mapname, data] of Object.entries(json)) {
|
||||
maps[mapname] = GeoMap._createMap(data)
|
||||
maps[mapname].name = mapname
|
||||
}
|
||||
} else console.error('Could not validate JSON: ' + error.message)
|
||||
|
||||
@@ -556,7 +554,6 @@ export class DeepZoomMap extends GeoMap {
|
||||
*/
|
||||
load(container = null, scatter = null) {
|
||||
this.info = new DeepZoomInfo(this.tilesConfig)
|
||||
console.log('APP:', this.mapdata.app)
|
||||
let image = new DeepZoomImage(this.info, {
|
||||
app: this.mapdata.app,
|
||||
alpha: this.alpha,
|
||||
@@ -614,7 +611,6 @@ export class DeepZoomMap extends GeoMap {
|
||||
|
||||
// Don't scale beyond boundaries.
|
||||
if (this.maxScale) targetScale = Math.min(this.maxScale, targetScale)
|
||||
|
||||
if (this.minScale) targetScale = Math.max(targetScale, this.minScale)
|
||||
|
||||
this.image.scatter.requestScale(targetScale)
|
||||
@@ -626,15 +622,12 @@ export class DeepZoomMap extends GeoMap {
|
||||
|
||||
let containerCenter
|
||||
if (this.frame) {
|
||||
containerCenter = this.getFrame().localCenter
|
||||
//console.log("HAS FRAME: ", containerCenter)
|
||||
containerCenter = this.getFrame().center
|
||||
} else {
|
||||
containerCenter = {
|
||||
x: this.image.parent.width / 2,
|
||||
y: this.image.parent.height / 2
|
||||
}
|
||||
|
||||
//console.log("GET CONTAINER CENTER")
|
||||
}
|
||||
|
||||
//Calculate the delta depending on image position and center the
|
||||
@@ -643,7 +636,6 @@ export class DeepZoomMap extends GeoMap {
|
||||
x: containerCenter.x - point.x * this.image.scatter.scale - this.scatter.position.x,
|
||||
y: containerCenter.y - point.y * this.image.scatter.scale - this.scatter.position.y
|
||||
}
|
||||
// console.log("MOVE TO: " , this.image.scatter.translatable,point, delta)
|
||||
|
||||
if (animate > 0) {
|
||||
let last = 0
|
||||
@@ -694,25 +686,6 @@ export class DeepZoomMap extends GeoMap {
|
||||
viewport: this.viewport
|
||||
})
|
||||
|
||||
//TODO: If frame is not set, the map does not work anymore.
|
||||
|
||||
//map.load(container, scatter)
|
||||
|
||||
// this.image.parent.children.forEach(child=>{
|
||||
// if(child instanceof PIXI.DisplayObject){
|
||||
|
||||
// if(child instanceof PIXI.Graphics){
|
||||
// // let clone = child.clone()
|
||||
// // const position = child.position
|
||||
// // clone.position.set(position.x, position.y)
|
||||
// // map.addChild(clone)
|
||||
// // console.log(map.mapLayer)
|
||||
|
||||
// }else console.log("DisplayObject is not yet implemented for cloning.", child)
|
||||
|
||||
// }else console.error("Not implemented object to clone: ", child)
|
||||
// })
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
@@ -765,7 +738,6 @@ export class ImageMap extends GeoMap {
|
||||
|
||||
load(container = null, scatter = null) {
|
||||
super.load(this.sprite, container, scatter)
|
||||
console.log('LOADED')
|
||||
this.image.alpha = this.alpha
|
||||
this.image.interactive = true
|
||||
}
|
||||
@@ -785,19 +757,9 @@ export class ImageMap extends GeoMap {
|
||||
})
|
||||
map.load(container, scatter)
|
||||
|
||||
console.log(map.image)
|
||||
return map
|
||||
}
|
||||
|
||||
// transformed(e) {
|
||||
// for (let key in this.overlays) {
|
||||
// this.overlays[key].forEach((overlay) => {
|
||||
// overlay.sprite.scale.x = overlay.scale / e.scale
|
||||
// overlay.sprite.scale.y = overlay.scale / e.scale
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -807,37 +769,6 @@ export class ImageMap extends GeoMap {
|
||||
* @memberof ImageMap
|
||||
*/
|
||||
moveTo(coordinates, zoom = null, { animate = 0 } = {}) {
|
||||
// console.log('Coordinates: ', coordinates)
|
||||
|
||||
// if (zoom) {
|
||||
// this.image.scatter.requestScale(zoom)
|
||||
// }
|
||||
|
||||
// if (coordinates) {
|
||||
// //Get pixel position of lat lang values
|
||||
// let offset = Points.multiplyScalar(this.coordinatesToPoint(coordinates), this.scatter.scale)
|
||||
|
||||
// let frame = this.getFrame()
|
||||
// console.log(frame)
|
||||
|
||||
// //Calculate the delta depending on image position and center the
|
||||
// // desired position in the frame.
|
||||
// let delta = {
|
||||
// x: frame.center.x - offset.x - this.scatter.position.x,
|
||||
// y: frame.center.y - offset.y - this.scatter.position.y
|
||||
// }
|
||||
|
||||
// console.log('Move to: ', offset, frame, delta)
|
||||
|
||||
// if (this.image) {
|
||||
// if (animate > 0) {
|
||||
// console.log(animate)
|
||||
// //TODO Replace this with a more robus manipulation method (RequestMovement + animation)
|
||||
// this.image.scatter.move(delta, { animate })
|
||||
// //Requesting the transform dhoul be okay. Maybe also replace with an request mehtod.
|
||||
// } else this.image.scatter.transform(delta, /*ratio*/ 1, 0, { x: 0, y: 0 })
|
||||
// } else console.error('Imge was not loaded yet.')
|
||||
// }
|
||||
|
||||
if (this.image.scatter == null) {
|
||||
return
|
||||
@@ -867,14 +798,11 @@ export class ImageMap extends GeoMap {
|
||||
let containerCenter
|
||||
if (this.frame) {
|
||||
containerCenter = this.getFrame().localCenter
|
||||
//console.log("HAS FRAME: ", containerCenter)
|
||||
} else {
|
||||
containerCenter = {
|
||||
x: this.image.parent.width / 2,
|
||||
y: this.image.parent.height / 2
|
||||
}
|
||||
|
||||
//console.log("GET CONTAINER CENTER")
|
||||
}
|
||||
|
||||
//Calculate the delta depending on image position and center the
|
||||
@@ -884,7 +812,6 @@ export class ImageMap extends GeoMap {
|
||||
x: containerCenter.x - point.x * this.image.scatter.scale - this.scatter.position.x,
|
||||
y: containerCenter.y - point.y * this.image.scatter.scale - this.scatter.position.y
|
||||
}
|
||||
// console.log("MOVE TO: " , this.image.scatter.translatable,point, delta)
|
||||
|
||||
if (animate > 0) {
|
||||
let last = 0
|
||||
|
||||
Reference in New Issue
Block a user