@lgv/visualization-map 1.0.2 → 1.0.4

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": "@lgv/visualization-map",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "ES6 d3.js core visualization scaffold object and utilities for maps.",
6
6
  "main": "src/index.js",
@@ -44,7 +44,7 @@
44
44
  "webpack-dev-server": "^5.0.4"
45
45
  },
46
46
  "dependencies": {
47
- "@lgv/visualization-chart": "^1.0.5",
47
+ "@lgv/visualization-chart": "^1.1.3",
48
48
  "leaflet": "^1.9.4"
49
49
  },
50
50
  "ava": {
@@ -1,5 +1,5 @@
1
1
  import { select } from "d3-selection";
2
- import { debounce, LinearGrid } from "@lgv/visualization-chart";
2
+ import { LinearGrid } from "@lgv/visualization-chart";
3
3
  import { mean } from "d3-array";
4
4
  import L from "leaflet";
5
5
  import "leaflet/dist/leaflet.css";
@@ -24,13 +24,22 @@ class VisualizationMap extends LinearGrid {
24
24
  // initialize inheritance
25
25
  super(data, width, height, MapData, label, name);
26
26
 
27
- // determine x/y center
28
- let x = mean(this.data.features, d => typeof(d.geometry.coordinates[0]) == "object" ? mean(d.geometry.coordinates.map(x => x[1]).flat()) : d.geometry.coordinates[1]);
29
- let y = mean(this.data.features, d => typeof(d.geometry.coordinates[0]) == "object" ? mean(d.geometry.coordinates.map(x => x[0]).flat()) : d.geometry.coordinates[0]);
27
+ let x = 0;
28
+ let y = 0;
29
+
30
+ if (this.data) {
31
+
32
+ // determine x/y center based on provided data
33
+ let x = mean(this.data.features, d => typeof(d.geometry.coordinates[0]) == "object" ? mean(d.geometry.coordinates.map(x => x[1]).flat()) : d.geometry.coordinates[1]);
34
+ let y = mean(this.data.features, d => typeof(d.geometry.coordinates[0]) == "object" ? mean(d.geometry.coordinates.map(x => x[0]).flat()) : d.geometry.coordinates[0]);
35
+
36
+ }
30
37
 
31
38
  // update self
32
39
  this.center = [x,y];
40
+ this.debounceDelay = 500;
33
41
  this.map = null;
42
+ this.moveendTimeout = null;
34
43
  this.tileServerUrl = tileServerUrl;
35
44
  this.zoom = 1;
36
45
 
@@ -57,7 +66,10 @@ class VisualizationMap extends LinearGrid {
57
66
  * Attach event handlers for map events.
58
67
  */
59
68
  attachEvents() {
60
- this.map.on("moveend", debounce(() => this.processMoveEnd(),2000));
69
+ this.map.on("moveend", () => {
70
+ clearTimeout(this.moveendTimeout);
71
+ this.moveendTimeout = setTimeout(() => this.processMoveEnd(),this.debounceDelay);
72
+ });
61
73
  }
62
74
 
63
75
  /**