From 0a30712e31a847220e7e858421a9e01bb210df09 Mon Sep 17 00:00:00 2001 From: Severin Opel Date: Tue, 5 Nov 2019 11:23:18 +0100 Subject: [PATCH] Fixed overlay example to work with restructured GeoLayers. --- dist/iwmlib.pixi.js | 18 ++++++++---------- lib/pixi/maps/geolayer.js | 8 +++++++- lib/pixi/maps/map.js | 3 --- lib/pixi/maps/mapapp.js | 3 --- lib/pixi/maps/mapview.js | 2 -- lib/pixi/maps/overlay.html | 3 +-- lib/pixi/maps/overlay.js | 2 +- 7 files changed, 17 insertions(+), 22 deletions(-) diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index 46847f5..7dacc5c 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -17809,7 +17809,6 @@ * @param {ScatterEvent}[e] - Contains informations on how the element was transformed. */ transformed(e) { - console.log(this.name); this.onTransform.call(this, e); } @@ -18023,7 +18022,6 @@ y: frame.height / 2 }; - console.log(frame); frame.center = { x: frame.x + frame.localCenter.x, y: frame.y + frame.localCenter.y @@ -18574,7 +18572,6 @@ get zoomFactor() { let factor = this.baseZoomHeight / this.sprite.texture.height; - console.log(factor); return factor } } @@ -18611,7 +18608,6 @@ } transformed(map) { - console.log('MAPVIEW RECEIVED TRANSFORM'); this.updateZoom(map); this.updateFocusPoint(map); } @@ -18634,7 +18630,6 @@ if (map instanceof DeepZoomMap) this._zoom = map.floatingLevelForScale(map.image.scatter.scale); else { this._zoom = map.zoom; - console.warn('Zoom is not yet correctly implemented in this Map type: ' + map); } } @@ -19681,6 +19676,10 @@ } } + addChild(element) { + this.displayObject.addChild(element); + } + /** * Adapts to a map. If the maplayer should adapt to the parent maplayer, * no parameter must be specified. @@ -19888,8 +19887,10 @@ this.adapt(); this.changeHandler.call(this, map, oldMap); - this.map.onTransform.add(this.transformed.bind(this)); + //Call transform one time manually. + this.transformed(); + this.map.onTransform.add(this.transformed.bind(this)); } else { console.error("Could not set map, it's not of type GeoMap.", map); } @@ -20757,7 +20758,6 @@ } this.mapList = new MapList(opts.startmap ? opts.startmap : null, opts.maps ? opts.maps : {}); - console.log(this.mapList); this._setupKeyboardUtils(); } @@ -20910,7 +20910,6 @@ // } // }) - console.log(this.map); this.map.onTransform.add(this.transformed.bind(this)); this.transformed(); @@ -20920,7 +20919,6 @@ const parent = this.ui.parent; parent.removeChild(this.ui); parent.addChild(this.ui); - console.log('BRING TO FRONT!'); } } @@ -21755,7 +21753,7 @@ adjustItems = null } = {}) { const name = this.name[0].toUpperCase() + this.name.slice(1).toLowerCase() + ' Overlay'; - let geoLayer = new GeoLayer({ name }); + let geoLayer = new GeoLayer(new PIXI.Container(), { name }); if (this.rescale) geoLayer.rescale = this.rescale; this.items.forEach(item => { if (!excludeItems(item)) { diff --git a/lib/pixi/maps/geolayer.js b/lib/pixi/maps/geolayer.js index 51397b1..ab19f4f 100644 --- a/lib/pixi/maps/geolayer.js +++ b/lib/pixi/maps/geolayer.js @@ -41,6 +41,10 @@ export class GeoLayer { } } + addChild(element) { + this.displayObject.addChild(element) + } + /** * Adapts to a map. If the maplayer should adapt to the parent maplayer, * no parameter must be specified. @@ -248,8 +252,10 @@ export class MapLayer extends GeoLayer { this.adapt() this.changeHandler.call(this, map, oldMap) - this.map.onTransform.add(this.transformed.bind(this)) + //Call transform one time manually. + this.transformed() + this.map.onTransform.add(this.transformed.bind(this)) } else { console.error("Could not set map, it's not of type GeoMap.", map) } diff --git a/lib/pixi/maps/map.js b/lib/pixi/maps/map.js index 333cf37..578de7c 100644 --- a/lib/pixi/maps/map.js +++ b/lib/pixi/maps/map.js @@ -148,7 +148,6 @@ export class GeoMap { * @param {ScatterEvent}[e] - Contains informations on how the element was transformed. */ transformed(e) { - console.log(this.name) this.onTransform.call(this, e) } @@ -362,7 +361,6 @@ export class GeoMap { y: frame.height / 2 } - console.log(frame) frame.center = { x: frame.x + frame.localCenter.x, y: frame.y + frame.localCenter.y @@ -913,7 +911,6 @@ export class ImageMap extends GeoMap { get zoomFactor() { let factor = this.baseZoomHeight / this.sprite.texture.height - console.log(factor) return factor } } diff --git a/lib/pixi/maps/mapapp.js b/lib/pixi/maps/mapapp.js index 983d82c..3a6edd5 100644 --- a/lib/pixi/maps/mapapp.js +++ b/lib/pixi/maps/mapapp.js @@ -85,7 +85,6 @@ export default class MapApp extends PIXIApp { } this.mapList = new MapList(opts.startmap ? opts.startmap : null, opts.maps ? opts.maps : {}) - console.log(this.mapList) this._setupKeyboardUtils() } @@ -238,7 +237,6 @@ export default class MapApp extends PIXIApp { // } // }) - console.log(this.map) this.map.onTransform.add(this.transformed.bind(this)) this.transformed() @@ -248,7 +246,6 @@ export default class MapApp extends PIXIApp { const parent = this.ui.parent parent.removeChild(this.ui) parent.addChild(this.ui) - console.log('BRING TO FRONT!') } } diff --git a/lib/pixi/maps/mapview.js b/lib/pixi/maps/mapview.js index 90379a3..69c90fd 100644 --- a/lib/pixi/maps/mapview.js +++ b/lib/pixi/maps/mapview.js @@ -32,7 +32,6 @@ export default class MapView { } transformed(map) { - console.log('MAPVIEW RECEIVED TRANSFORM') this.updateZoom(map) this.updateFocusPoint(map) } @@ -55,7 +54,6 @@ export default class MapView { if (map instanceof DeepZoomMap) this._zoom = map.floatingLevelForScale(map.image.scatter.scale) else { this._zoom = map.zoom - console.warn('Zoom is not yet correctly implemented in this Map type: ' + map) } } diff --git a/lib/pixi/maps/overlay.html b/lib/pixi/maps/overlay.html index d5580e3..411db62 100644 --- a/lib/pixi/maps/overlay.html +++ b/lib/pixi/maps/overlay.html @@ -202,7 +202,6 @@ new PIXI.Sprite(textures.get(osmworld)), worlOSMData, { - cover: false, onLoaded: () => { worldOSMMap.setFrame(frame) } @@ -237,7 +236,7 @@ // When placed on the mapLayer, the PIXI Graphic elements, that // reside inside GeoGraphic Objects are placed automatically at the // correct coordinates of the map. - pointApp.mapLayer.place(exampleOverlayGeoLayer) + pointApp.mapLayer.addLayer(exampleOverlayGeoLayer) // Just a helper function that clears the popups and removes diff --git a/lib/pixi/maps/overlay.js b/lib/pixi/maps/overlay.js index 3cff470..6e897fb 100644 --- a/lib/pixi/maps/overlay.js +++ b/lib/pixi/maps/overlay.js @@ -186,7 +186,7 @@ export default class Overlay { adjustItems = null } = {}) { const name = this.name[0].toUpperCase() + this.name.slice(1).toLowerCase() + ' Overlay' - let geoLayer = new GeoLayer({ name }) + let geoLayer = new GeoLayer(new PIXI.Container(), { name }) if (this.rescale) geoLayer.rescale = this.rescale this.items.forEach(item => { if (!excludeItems(item)) {