Renamed 'MapView' to 'MapViewport'. Added documentation to the maps module.
This commit is contained in:
+72
-20
@@ -1,9 +1,9 @@
|
||||
import { GeoMap } from './map.js'
|
||||
import MapView from './mapview.js'
|
||||
import { EventHandler } from './utils.js'
|
||||
import { GeoGraphics } from './geographics.js'
|
||||
import { MapList } from './maplist.js'
|
||||
//import { GeoGraphics } from "../pixi/geographics.js"
|
||||
import MapViewport from './mapviewport.js'
|
||||
import { ScatterContainer } from '../scatter.js'
|
||||
|
||||
/**
|
||||
* The GeoLayer is a special PIXILayer, that recognizes other GeoLayers and
|
||||
@@ -93,6 +93,13 @@ export class GeoLayer {
|
||||
return this._visibility
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for geoLayer.displayObject.addChild.
|
||||
*
|
||||
* @public
|
||||
* @param {GeoGraphics | PIXI.DisplayObject} element - Element to add to the displayObject.
|
||||
* @memberof GeoLayer
|
||||
*/
|
||||
addChild(element) {
|
||||
this.displayObject.addChild(element)
|
||||
}
|
||||
@@ -117,15 +124,6 @@ export class GeoLayer {
|
||||
} else console.error('There was no map specified.', this)
|
||||
}
|
||||
|
||||
// place(geographic) {
|
||||
// if (geographic.constructor.name.startsWith('Geo') && geographic.graphics) {
|
||||
// // Fix to remove the rollupjs circular dependency
|
||||
// //if (geographic instanceof GeoGraphics) {
|
||||
// this.geographics.push(geographic)
|
||||
// super.place(geographic.graphics)
|
||||
// } else super.place(geographic)
|
||||
// }
|
||||
|
||||
removeFromParent() {
|
||||
if (this.parent) {
|
||||
this.parent.removeLayer(this)
|
||||
@@ -165,8 +163,15 @@ export class GeoLayer {
|
||||
return this._parent
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a GeoLayer as child to the GeoLayer.
|
||||
*
|
||||
* @public
|
||||
* @param {GeoLayer} layer - GeoLayer to add.
|
||||
* @memberof GeoLayer
|
||||
*/
|
||||
addLayer(layer) {
|
||||
if (layer instanceof GeoLayer || layer instanceof MapLayer) {
|
||||
if (layer instanceof GeoLayer) {
|
||||
layer.removeFromParent()
|
||||
|
||||
this.layers.push(layer)
|
||||
@@ -218,6 +223,18 @@ export class GeoLayer {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* The map layer is responsible for showing certain maps, at a specific position It contains
|
||||
* a list of available maps and can switch between them seamlessly. GeoGraphics placed on the MapLayer itself
|
||||
* or child Geolayers will be adapted to maps and adjusted on map change automatically.
|
||||
*
|
||||
* The map layer is the 'king' of the geo layers. Every geolayer
|
||||
* needs a map layer at it's root. Otherwise they won't work-
|
||||
*
|
||||
* @export
|
||||
* @class MapLayer
|
||||
* @extends {GeoLayer}
|
||||
*/
|
||||
export class MapLayer extends GeoLayer {
|
||||
constructor(
|
||||
mapList,
|
||||
@@ -247,7 +264,7 @@ export class MapLayer extends GeoLayer {
|
||||
listeners: onChange
|
||||
})
|
||||
|
||||
this.mapview = new MapView({
|
||||
this.mapview = new MapViewport({
|
||||
zoom,
|
||||
focus,
|
||||
viewport
|
||||
@@ -279,22 +296,34 @@ export class MapLayer extends GeoLayer {
|
||||
this._mapChangeLocked = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts all child layers and their GeoGraphics.
|
||||
*
|
||||
* This is called primarily on a map change.
|
||||
*
|
||||
* @private
|
||||
* @memberof MapLayer
|
||||
*/
|
||||
adapt() {
|
||||
this.layers.forEach(layer => {
|
||||
if (layer.adapt) layer.adapt(this.map)
|
||||
})
|
||||
}
|
||||
|
||||
focus(coordinates, zoom) {
|
||||
this.mapview.updateFocusPoint(this.map)
|
||||
}
|
||||
|
||||
transformed(e) {
|
||||
this.mapview.transformed(this.map)
|
||||
this.layers.forEach(layer => layer.parentMapLayerTransformed(this))
|
||||
this.transformHandler.call(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the map layer-
|
||||
*
|
||||
* @param {ScatterContainer} scatterContainer - ScatterContainer of the app.
|
||||
* @param {PIXI.DisplayObject} [container=null] - Container of the newly created MapLayer. If null, an empty PIXI.Container will be created.
|
||||
* @returns
|
||||
* @memberof MapLayer
|
||||
*/
|
||||
clone(scatterContainer, container = null) {
|
||||
let mapList = this.mapList.clone()
|
||||
container = container == null ? new PIXI.Container() : container
|
||||
@@ -369,23 +398,46 @@ export class MapLayer extends GeoLayer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the mapviews focus to the map.
|
||||
* This may be useful, if the container was modified.
|
||||
*
|
||||
* @memberof MapLayer
|
||||
*/
|
||||
refocus() {
|
||||
this.mapview.apply(this.map)
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @returns {GeoMap} - Returns the active map.
|
||||
* @readonly
|
||||
* @memberof MapLayer
|
||||
*/
|
||||
get map() {
|
||||
return this.mapList.map
|
||||
}
|
||||
|
||||
/**
|
||||
* This is required for the consistency of georelated layers.
|
||||
* The request traverses up to the mapLayer where it then returns
|
||||
* the responsible map layer.
|
||||
*
|
||||
* This is required for the geo layers.
|
||||
* MapLayer requests from the geoLayers traverse up to the next MapLayer.
|
||||
*
|
||||
* @public
|
||||
* @returns {MapLayer} - Returns this MapLayer.
|
||||
* @readonly
|
||||
* @memberof MapLayer
|
||||
*/
|
||||
get mapLayer() {
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the MapLayer.
|
||||
*
|
||||
* @public
|
||||
* @memberof MapLayer
|
||||
*/
|
||||
cleanup() {
|
||||
this.mapList.cleanup()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user