Renamed 'MapView' to 'MapViewport'. Added documentation to the maps module.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
* MapList is a list of maps with one active index.
|
||||
* It contains some utility functions to change the map.
|
||||
*
|
||||
* @export
|
||||
* @class MapList
|
||||
*/
|
||||
export class MapList {
|
||||
constructor(active = null, maps = {}) {
|
||||
this.maps = maps
|
||||
@@ -9,8 +16,9 @@ export class MapList {
|
||||
/**
|
||||
* Selects a map from the map list.
|
||||
*
|
||||
* @public
|
||||
* @param {string} active - Name of the map to select.
|
||||
* @returns
|
||||
* @returns {Map} - Returns the active map. Returns null if no map was added to the MapList.
|
||||
* @memberof MapList
|
||||
*/
|
||||
select(active) {
|
||||
@@ -40,6 +48,13 @@ export class MapList {
|
||||
return map
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the entire maplist.
|
||||
*
|
||||
* @public
|
||||
* @returns {MapList} - Returns a cloned instance of this map list.
|
||||
* @memberof MapList
|
||||
*/
|
||||
clone() {
|
||||
let maps = {}
|
||||
|
||||
@@ -50,6 +65,14 @@ export class MapList {
|
||||
return new MapList(this.active, maps)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new map to the map list.
|
||||
*
|
||||
* @public
|
||||
* @param {string} key - Key to identify the map.
|
||||
* @param {GeoMap} map - The GeoMap to add.
|
||||
* @memberof MapList
|
||||
*/
|
||||
add(key, map) {
|
||||
if (this.maps[key] != null) consol.warn('Key already in mapList. The existing key was overwritten.')
|
||||
if (this.active == null) this.active = key
|
||||
@@ -57,10 +80,25 @@ export class MapList {
|
||||
this.maps[key] = map
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the the active map.
|
||||
* If none is set, it returns null.
|
||||
*
|
||||
*@public
|
||||
* @readonly
|
||||
* @memberof MapList
|
||||
*/
|
||||
get map() {
|
||||
return this.maps && this.maps[this.active] ? this.maps[this.active] : null
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the next map in the map array.
|
||||
*
|
||||
* @public
|
||||
* @returns {GeoMap} - Returns the next map in the list.
|
||||
* @memberof MapList
|
||||
*/
|
||||
next() {
|
||||
let keys = Object.keys(this.maps)
|
||||
let idx = keys.indexOf(this.active)
|
||||
@@ -69,6 +107,13 @@ export class MapList {
|
||||
return next
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all maps from the maplist.
|
||||
* And cleans up all maps.
|
||||
*
|
||||
* @public
|
||||
* @memberof MapList
|
||||
*/
|
||||
cleanup() {
|
||||
for (let key in this.maps) {
|
||||
let map = this.maps[key]
|
||||
|
||||
Reference in New Issue
Block a user