Skip to content
Snippets Groups Projects

F map marker color config

Merged Timm Fitschen requested to merge f-map-marker-color-config into dev
All threads resolved!
Files
3
+ 31
17
@@ -25,7 +25,7 @@
@@ -25,7 +25,7 @@
/**
/**
* @module caosdb_map
* @module caosdb_map
* @version 0.4.1
* @version 0.5.0
*
*
* For displaying a geographical map which shows entities at their associated
* For displaying a geographical map which shows entities at their associated
* geolocation.
* geolocation.
@@ -43,7 +43,7 @@
@@ -43,7 +43,7 @@
var caosdb_map = new function () {
var caosdb_map = new function () {
var logger = log.getLogger("caosdb_map");
var logger = log.getLogger("caosdb_map");
this.version = "0.4.1";
this.version = "0.5.0";
this.dependencies = ["log", {
this.dependencies = ["log", {
"L": ["latlngGraticule", "Proj"]
"L": ["latlngGraticule", "Proj"]
}, "navbar", "caosdb_utils"];
}, "navbar", "caosdb_utils"];
@@ -76,6 +76,8 @@ var caosdb_map = new function () {
@@ -76,6 +76,8 @@ var caosdb_map = new function () {
* @property {DataModelConfig} datamodel - the data model for the
* @property {DataModelConfig} datamodel - the data model for the
* display of entities in the map (also used by the query generator).
* display of entities in the map (also used by the query generator).
* @property {SelectConfig} select - config for the query generator.
* @property {SelectConfig} select - config for the query generator.
 
* @property {Object.<string, EntityLayerConfig>} entityLayers -
 
* configuration for the entity layer which are to be shown on the map.
*/
*/
/**
/**
@@ -382,14 +384,23 @@ var caosdb_map = new function () {
@@ -382,14 +384,23 @@ var caosdb_map = new function () {
*/
*/
/**
/**
 
* Configuration of the entity layers which are to be shown on the map.
 
*
* @typedef {object} EntityLayerConfig
* @typedef {object} EntityLayerConfig
* @property {string} id
* @property {string} id - the id of the entity layer which is used
* @property {string} name
* internally.
* @property {string} description
* @property {string} name - a short name which is shown in the entity
* @property {DivIcon_options} icon_options
* layers menu.
 
* @property {string} description - a short description which is shown as
 
* hover-over text in the entity layers menu.
 
* @property {DivIcon_options} icon_tions - leaflet options for the icon
 
* (aka the marker) which is shown on the map. These options are
 
* espcially useful to style the icons (color etc).
* @property {number} zIndexOffset
* @property {number} zIndexOffset
* @property {mapEntityGetter} get_entities
* @property {mapEntityGetter} get_entities - returns the entities which
* @property {mapEntityPopupGenerator} make_popup
* are to be shown on the map.
 
* @property {mapEntityPopupGenerator} make_popup - returns the popup which
 
* is to be shown when a user clicks on the map marker.
*/
*/
/**
/**
@@ -647,13 +658,13 @@ var caosdb_map = new function () {
@@ -647,13 +658,13 @@ var caosdb_map = new function () {
* "all_map_entities" which shows all entities in the database with
* "all_map_entities" which shows all entities in the database with
* coordinates.
* coordinates.
*
*
* @type {EntityLayerConfig[]}
* @type {Object.<string, EntityLayerConfig>}
*/
*/
this._default_entity_layer_config = {
this._default_entity_layer_config = {
"current_page_entities": {
"current_page_entities": {
"name": "Entities on the current page.",
"name": "Entities on the current page.",
"description": "Show all entities on the current page.",
"description": "Show all entities on the current page.",
"icon": {
"icon_options": {
html: '<i class="bi-geo-alt-fill" style="font-size: 20px; color: #00F;"></i>',
html: '<i class="bi-geo-alt-fill" style="font-size: 20px; color: #00F;"></i>',
iconAnchor: [10, 19],
iconAnchor: [10, 19],
className: "",
className: "",
@@ -675,7 +686,7 @@ var caosdb_map = new function () {
@@ -675,7 +686,7 @@ var caosdb_map = new function () {
"all_map_entities": {
"all_map_entities": {
"name": "All entities",
"name": "All entities",
"description": "Show all entities with coordinates.",
"description": "Show all entities with coordinates.",
"icon": {
"icon_options": {
html: '<i class="bi-geo-alt-fill" style="font-size: 20px; color: #F00;"></i>',
html: '<i class="bi-geo-alt-fill" style="font-size: 20px; color: #F00;"></i>',
iconAnchor: [10, 19],
iconAnchor: [10, 19],
className: "",
className: "",
@@ -973,9 +984,10 @@ var caosdb_map = new function () {
@@ -973,9 +984,10 @@ var caosdb_map = new function () {
this._reload_layers = function () {
this._reload_layers = function () {
caosdb_map._show_load_info()
caosdb_map._show_load_info()
const promises = []
const promises = []
 
const entity_layer_config = $.extend(true, {}, caosdb_map._default_entity_layer_config, caosdb_map.config["entityLayers"]);
for (const layer of caosdb_map.layers) {
for (const layer of caosdb_map.layers) {
promises.push(caosdb_map._fill_layer(layer.layer_group,
promises.push(caosdb_map._fill_layer(layer.layer_group,
caosdb_map._default_entity_layer_config[layer.id]));
entity_layer_config[layer.id]));
}
}
Promise.all(promises).then((val) => {
Promise.all(promises).then((val) => {
caosdb_map._hide_load_info()
caosdb_map._hide_load_info()
@@ -1067,14 +1079,16 @@ var caosdb_map = new function () {
@@ -1067,14 +1079,16 @@ var caosdb_map = new function () {
view_config);
view_config);
// init entity layers
// init entity layers
this.layers = this.init_entity_layers(this._default_entity_layer_config);
const entity_layer_config = $.extend(true, {}, this._default_entity_layer_config, config["entityLayers"]);
 
caosdb_map.entityLayers = entity_layer_config;
 
this.layers = this.init_entity_layers(entity_layer_config);
var layerControl = L.control.layers();
var layerControl = L.control.layers();
const promises = []
const promises = []
for (const layer of this.layers) {
for (const layer of this.layers) {
promises.push(caosdb_map._fill_layer(layer.layer_group,
promises.push(caosdb_map._fill_layer(layer.layer_group,
this._default_entity_layer_config[layer.id]));
entity_layer_config[layer.id]));
layerControl.addOverlay(layer.layer_group, layer.chooser_html.outerHTML);
layerControl.addOverlay(layer.layer_group, layer.chooser_html.outerHTML);
layer.layer_group.addTo(this._map);
layer.layer_group.addTo(this._map);
}
}
@@ -1139,7 +1153,7 @@ var caosdb_map = new function () {
@@ -1139,7 +1153,7 @@ var caosdb_map = new function () {
*/
*/
/**
/**
* @param {EntityLayerConfig[]} configs
* @param {Object.<string, EntityLayerConfig>} config
* @returns {_EntityLayer[]}
* @returns {_EntityLayer[]}
*/
*/
this.init_entity_layers = function (configs) {
this.init_entity_layers = function (configs) {
@@ -1165,7 +1179,7 @@ var caosdb_map = new function () {
@@ -1165,7 +1179,7 @@ var caosdb_map = new function () {
layer_group.entities = entities;
layer_group.entities = entities;
var markers = caosdb_map.create_entity_markers(
var markers = caosdb_map.create_entity_markers(
entities, config.datamodel, config.make_popup,
entities, config.datamodel, config.make_popup,
config.zIndexOffset, config.icon);
config.zIndexOffset, config.icon_options);
for (const marker of markers) {
for (const marker of markers) {
layer_group.addLayer(marker);
layer_group.addLayer(marker);
@@ -1202,7 +1216,7 @@ var caosdb_map = new function () {
@@ -1202,7 +1216,7 @@ var caosdb_map = new function () {
this.make_layer_chooser_html = function (config) {
this.make_layer_chooser_html = function (config) {
return $('<span/>')
return $('<span/>')
.attr("title", config.description)
.attr("title", config.description)
.append(config.icon.html)
.append(config.icon_options.html)
.append(config.name)[0];
.append(config.name)[0];
}
}
Loading