Skip to content
Snippets Groups Projects

ENH: add "show" option to map config

Merged Timm Fitschen requested to merge f-show-map into dev
All threads resolved!
Files
3
+ 21
7
@@ -25,7 +25,7 @@
/**
* @module caosdb_map
* @version 0.4
* @version 0.4.1
*
* For displaying a geographical map which shows entities at their associated
* geolocation.
@@ -34,7 +34,7 @@
* `conf/ext/json/ext_map.json` and comply with the {@link MapConfig} type
* which is described below.
*
* The current version is 0.4. It is not considered to be stable because
* The current version is 0.4.1. It is not considered to be stable because
* implementation of the graticule still is not satisfactory.
*
* Apart from that the specification of the configuration and the
@@ -43,7 +43,7 @@
var caosdb_map = new function () {
var logger = log.getLogger("caosdb_map");
this.version = "0.4";
this.version = "0.4.1";
this.dependencies = ["log", {
"L": ["latlngGraticule", "Proj"]
}, "navbar", "caosdb_utils"];
@@ -63,6 +63,9 @@ var caosdb_map = new function () {
* integrated query generator.
*
* @typedef {object} MapConfig
* @property {boolean} [show=false] - show the map immediately when it is
* ready. This configuration option is being stored locally for keeping
* the map shown/hidden accross page reloads.
* @property {string} version - the version of the map
* @property {string} default_view - the view which is shown when the user
* opens the map and has no stored view from prior visits to the map.
@@ -336,6 +339,7 @@ var caosdb_map = new function () {
*/
this._default_config = {
"version": this.version,
"show": false,
"datamodel": {
"lat": "latitude",
"lng": "longitude",
@@ -843,8 +847,10 @@ var caosdb_map = new function () {
*
* The map panel is the HTMLElement which contains the map. Is is
* hidden or shown when the user clicks on the toggle map button.
*
* @param {boolean} show - show this panel immediately.
*/
this.init_map_panel = function () {
this.init_map_panel = function (show) {
logger.trace("enter init_map_panel");
// remove old
@@ -852,7 +858,9 @@ var caosdb_map = new function () {
let panel = this.create_map_panel();
$(panel).hide();
if(!show) {
$(panel).hide();
}
$('nav').first().after(panel);
logger.trace("leave init_map_panel");
@@ -865,6 +873,7 @@ var caosdb_map = new function () {
*/
this.toggle_map = function () {
logger.trace("enter toggle_map");
sessionStorage["caosdb_map.show"] = !$(".caosdb-f-map-panel").is(":visible");
$(".caosdb-f-map-panel").toggle(900, () => this
._toggle_cb());
}
@@ -872,6 +881,7 @@ var caosdb_map = new function () {
this.show_map = function () {
logger.trace("enter show_map");
sessionStorage["caosdb_map.show"] = "true";
$(".caosdb-f-map-panel").show(900, () => this
._toggle_cb());
}
@@ -983,14 +993,18 @@ var caosdb_map = new function () {
return;
}
this.config = config;
var show_map = config.show;
if(sessionStorage["caosdb_map.show"]) {
show_map = JSON.parse(sessionStorage["caosdb_map.show"]);
}
this.init_select_handler();
this.init_view_change_handler();
panel = this.init_map_panel();
panel = this.init_map_panel(show_map);
// TODO split in smaller pieces and move callback to separate function
this.change_map_view = (view) => {
if (this._map) {
this._map._container.remove();
this._map._container.remove();
this._map.remove();
}
Loading