gridviz 3.0.34 → 3.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridviz",
3
- "version": "3.0.34",
3
+ "version": "3.0.35",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
package/src/core/Map.js CHANGED
@@ -90,6 +90,12 @@ export class Map {
90
90
  * @type {Tooltip} */
91
91
  this.tooltip = new Tooltip(opts.tooltip)
92
92
 
93
+ /**
94
+ * Set to true so that the tooltip appears for the first layer starting from top where a cell is found.
95
+ * Otherwise, it shows a tooltip only for the first layer from the top with a cellInfoHTML property, even if there is no cell at the mouse position for this layer.
96
+ * @type {boolean} */
97
+ this.digForTooltip = opts.digForTooltip || false
98
+
93
99
  // add event listeners to container
94
100
  this.mouseOverHandler = (e) => this.focusCell(e)
95
101
  this.mouseMoveHandler = (e) => this.focusCell(e)
@@ -330,15 +336,20 @@ export class Map {
330
336
  * @protected
331
337
  */
332
338
  getCellFocusInfo(posGeo) {
333
- //go through the layers, starting from top
339
+
340
+ // go through the layers, starting from top one
334
341
  const z = this.geoCanvas.view.z
335
342
  for (let i = this.layers.length - 1; i >= 0; i--) {
343
+
336
344
  /** @type {import("./Layer.js").Layer} */
337
345
  const layer = this.layers[i]
346
+
338
347
  if (layer.visible && !layer.visible(z)) continue
339
- if (layer.cellInfoHTML === 'none') continue // this is necessary in order to not show tooltips for layers 'on top' (e.g. population circles on top of squares)
348
+ if (layer.cellInfoHTML === 'none') continue
340
349
  if (!layer.cellInfoHTML) continue
341
350
  if (!layer.getDataset) continue
351
+
352
+ // get dataset
342
353
  const dsc = layer.getDataset(z)
343
354
  if (!dsc) continue
344
355
 
@@ -346,7 +357,12 @@ export class Map {
346
357
  /** @type {import('./Dataset.js').Cell|undefined} */
347
358
  const cell = dsc.getCellFromPosition(posGeo, dsc.getViewCache())
348
359
 
349
- if (!cell) return undefined
360
+ // no cell found at theis position for this layer
361
+ if (!cell)
362
+ // dig to the next layer below
363
+ if (this.digForTooltip) continue
364
+ // no tooltip to show
365
+ else return undefined
350
366
 
351
367
  //rare case for a dataset with mixed resolutions
352
368
  if (dsc.mixedResolution) {