@hpcc-js/map 3.5.4 → 3.5.6

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.
Files changed (95) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +88 -88
  3. package/TopoJSON/BR.json +122 -122
  4. package/TopoJSON/GB_idx.json +1 -1
  5. package/TopoJSON/IE_idx.json +1 -1
  6. package/TopoJSON/ND_idx.json +1 -1
  7. package/TopoJSON/countries.json +257 -257
  8. package/TopoJSON/us-counties.json +16550 -16550
  9. package/TopoJSON/us-states.json +458 -458
  10. package/dist/index.js +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.umd.cjs +1 -1
  13. package/dist/index.umd.cjs.map +1 -1
  14. package/package.json +12 -10
  15. package/src/CanvasPinLayer.ts +99 -99
  16. package/src/CanvasPins.ts +397 -397
  17. package/src/Choropleth.css +26 -26
  18. package/src/Choropleth.ts +203 -203
  19. package/src/ChoroplethContinents.ts +13 -13
  20. package/src/ChoroplethCounties.ts +111 -111
  21. package/src/ChoroplethCountries.ts +100 -100
  22. package/src/ChoroplethStates.ts +103 -103
  23. package/src/ChoroplethStatesHeat.ts +8 -8
  24. package/src/GMap.css +20 -20
  25. package/src/GMap.ts +880 -880
  26. package/src/GMapCounties.ts +93 -93
  27. package/src/GMapGraph.ts +61 -61
  28. package/src/GMapHeat.ts +27 -27
  29. package/src/GMapLayered.ts +94 -94
  30. package/src/GMapPin.ts +115 -115
  31. package/src/GMapPinLine.ts +138 -138
  32. package/src/GeoHash.css +14 -14
  33. package/src/GeoHash.ts +139 -139
  34. package/src/Graph.css +9 -9
  35. package/src/Graph.ts +98 -98
  36. package/src/Graticule.css +12 -12
  37. package/src/Graticule.ts +97 -97
  38. package/src/Heat.ts +87 -87
  39. package/src/IChoropleth.ts +8 -8
  40. package/src/Layer.ts +99 -99
  41. package/src/Layered.css +18 -18
  42. package/src/Layered.ts +206 -206
  43. package/src/Lines.css +8 -8
  44. package/src/Lines.ts +78 -78
  45. package/src/OpenStreet.css +15 -15
  46. package/src/OpenStreet.ts +126 -126
  47. package/src/Pins.css +17 -17
  48. package/src/Pins.ts +350 -350
  49. package/src/Projection.ts +42 -42
  50. package/src/TestHeatMap.ts +8 -8
  51. package/src/TopoJSONChoropleth.ts +125 -125
  52. package/src/Utility.ts +484 -484
  53. package/src/__package__.ts +3 -3
  54. package/src/index.ts +33 -33
  55. package/src/leaflet/AlbersPR.ts +48 -48
  56. package/src/leaflet/Blank.ts +9 -9
  57. package/src/leaflet/Circles.ts +139 -139
  58. package/src/leaflet/ClusterCircles.css +26 -26
  59. package/src/leaflet/ClusterCircles.ts +88 -88
  60. package/src/leaflet/Countries.ts +43 -43
  61. package/src/leaflet/DrawLayer.ts +167 -167
  62. package/src/leaflet/FeatureLayer.ts +138 -138
  63. package/src/leaflet/GMap.ts +44 -44
  64. package/src/leaflet/HeatLayer.ts +77 -77
  65. package/src/leaflet/Icons.ts +60 -60
  66. package/src/leaflet/Leaflet.css +3 -3
  67. package/src/leaflet/Leaflet.ts +239 -239
  68. package/src/leaflet/MapBox.ts +35 -35
  69. package/src/leaflet/Markers.ts +109 -109
  70. package/src/leaflet/OpenStreet.ts +27 -27
  71. package/src/leaflet/Path.ts +138 -138
  72. package/src/leaflet/Pins.ts +73 -73
  73. package/src/leaflet/Polygons.ts +113 -113
  74. package/src/leaflet/Region.ts +138 -138
  75. package/src/leaflet/Text.ts +99 -99
  76. package/src/leaflet/TileLayer.ts +81 -81
  77. package/src/leaflet/TopoJSON.ts +146 -146
  78. package/src/leaflet/US.ts +15 -15
  79. package/src/leaflet/USCounties.ts +43 -43
  80. package/src/leaflet/USStates.ts +41 -41
  81. package/src/leaflet/World.css +3 -3
  82. package/src/leaflet/World.ts +172 -172
  83. package/src/leaflet/index.ts +18 -18
  84. package/src/leaflet/leaflet-shim.ts +18 -18
  85. package/src/leaflet/plugins/BeautifyIcon.css +44 -44
  86. package/src/leaflet/plugins/BeautifyIcon.ts +190 -190
  87. package/src/leaflet/plugins/BeutifyIcon.licence +20 -20
  88. package/src/leaflet/plugins/D3SvgOverlay.css +2 -2
  89. package/src/leaflet/plugins/D3SvgOverlay.licence +20 -20
  90. package/src/leaflet/plugins/D3SvgOverlay.ts +175 -175
  91. package/src/leaflet/plugins/HeatLayer.license +21 -21
  92. package/src/leaflet/plugins/HeatLayer.ts +224 -224
  93. package/src/leaflet/plugins/Leaflet.GoogleMutant.ts +424 -424
  94. package/src/leaflet/plugins/lru_map.ts +352 -352
  95. package/src/test.ts +114 -114
@@ -1,224 +1,224 @@
1
- import * as L from "leaflet";
2
- import * as _simpleheat from "simpleheat";
3
-
4
- const simpleheat = (window as any).simpleheat || (_simpleheat && _simpleheat.default) || _simpleheat;
5
-
6
- /* Ported from https://github.com/Leaflet/Leaflet.heat
7
- Changes:
8
- * Ported to TypeScript
9
- */
10
-
11
- export class LeafletLayer2 extends L.Layer {
12
- }
13
-
14
- export class HeatLayer extends LeafletLayer2 {
15
- _latlngs: any;
16
- _heat: any;
17
- _frame: any;
18
- _canvas: any;
19
-
20
- // options: {
21
- // minOpacity: 0.05,
22
- // maxZoom: 18,
23
- // radius: 25,
24
- // blur: 15,
25
- // max: 1.0
26
- // }
27
-
28
- constructor(latlngs, options = {}) {
29
- super(options);
30
- this._latlngs = latlngs;
31
- }
32
-
33
- initialize(options) {
34
- this.setOptions(options);
35
- }
36
-
37
- setLatLngs(latlngs) {
38
- this._latlngs = latlngs;
39
- return this.redraw();
40
- }
41
-
42
- addLatLng(latlng) {
43
- this._latlngs.push(latlng);
44
- return this.redraw();
45
- }
46
-
47
- setOptions(options) {
48
- this.options = options;
49
- if (this._heat) {
50
- this._updateOptions();
51
- }
52
- return this.redraw();
53
- }
54
-
55
- redraw() {
56
- if (this._heat && !this._frame && !this._map["_animating"]) {
57
- this._frame = L.Util.requestAnimFrame(this._redraw, this);
58
- }
59
- return this;
60
- }
61
-
62
- onAdd(map): this {
63
- this._map = map;
64
-
65
- if (!this._canvas) {
66
- this._initCanvas();
67
- }
68
-
69
- map._panes.overlayPane.appendChild(this._canvas);
70
-
71
- map.on("moveend", this._reset, this);
72
-
73
- if (map.options.zoomAnimation && L.Browser.any3d) {
74
- map.on("zoomanim", this._animateZoom, this);
75
- }
76
-
77
- this._reset();
78
- return this;
79
- }
80
-
81
- onRemove(map): this {
82
- map.getPanes().overlayPane.removeChild(this._canvas);
83
-
84
- map.off("moveend", this._reset, this);
85
-
86
- if (map.options.zoomAnimation) {
87
- map.off("zoomanim", this._animateZoom, this);
88
- }
89
- return this;
90
- }
91
-
92
- addTo(map) {
93
- map.addLayer(this);
94
- return this;
95
- }
96
-
97
- _initCanvas() {
98
- const canvas: any = this._canvas = L.DomUtil.create("canvas", "leaflet-heatmap-layer leaflet-layer");
99
-
100
- const originProp = L.DomUtil.testProp(["transformOrigin", "WebkitTransformOrigin", "msTransformOrigin"]);
101
- canvas.style[originProp as string] = "50% 50%";
102
-
103
- const size = this._map.getSize();
104
- canvas.width = size.x;
105
- canvas.height = size.y;
106
-
107
- const animated = this._map.options.zoomAnimation && L.Browser.any3d;
108
- L.DomUtil.addClass(canvas, "leaflet-zoom-" + (animated ? "animated" : "hide"));
109
-
110
- this._heat = simpleheat(canvas);
111
- this._updateOptions();
112
- }
113
-
114
- _updateOptions() {
115
- this._heat.radius(this.options["radius"] || this._heat.defaultRadius, this.options["blur"]);
116
-
117
- if (this.options["gradient"]) {
118
- this._heat.gradient(this.options["gradient"]);
119
- }
120
- if (this.options["max"]) {
121
- this._heat.max(this.options["max"]);
122
- }
123
- }
124
-
125
- _reset() {
126
- const topLeft = this._map.containerPointToLayerPoint([0, 0]);
127
- L.DomUtil.setPosition(this._canvas, topLeft);
128
-
129
- const size = this._map.getSize();
130
-
131
- if (this._heat._width !== size.x) {
132
- this._canvas.width = this._heat._width = size.x;
133
- }
134
- if (this._heat._height !== size.y) {
135
- this._canvas.height = this._heat._height = size.y;
136
- }
137
-
138
- this._redraw();
139
- }
140
-
141
- _redraw() {
142
- const data = [];
143
- const r = this._heat._r;
144
- const size = this._map.getSize();
145
- const bounds = new L.Bounds(L.point([-r, -r]), size.add([r, r]));
146
- const max = this.options["max"] === undefined ? 1 : this.options["max"];
147
- const maxZoom = this.options["maxZoom"] === undefined ? this._map.getMaxZoom() : this.options["maxZoom"];
148
- const v = 1 / Math.pow(2, Math.max(0, Math.min(maxZoom - this._map.getZoom(), 12)));
149
- const cellSize = r / 2;
150
- const grid = [];
151
- const panePos = this._map["_getMapPanePos"]();
152
- const offsetX = panePos.x % cellSize;
153
- const offsetY = panePos.y % cellSize;
154
- let i;
155
- let len;
156
- let p;
157
- let cell;
158
- let x;
159
- let y;
160
- let j;
161
- let len2;
162
- let k;
163
-
164
- // console.time('process');
165
- for (i = 0, len = this._latlngs.length; i < len; i++) {
166
- p = this._map.latLngToContainerPoint(this._latlngs[i]);
167
- if (bounds.contains(p)) {
168
- x = Math.floor((p.x - offsetX) / cellSize) + 2;
169
- y = Math.floor((p.y - offsetY) / cellSize) + 2;
170
-
171
- const alt =
172
- this._latlngs[i].alt !== undefined ? this._latlngs[i].alt :
173
- this._latlngs[i][2] !== undefined ? +this._latlngs[i][2] : 1;
174
- k = alt * v;
175
-
176
- grid[y] = grid[y] || [];
177
- cell = grid[y][x];
178
-
179
- if (!cell) {
180
- grid[y][x] = [p.x, p.y, k];
181
-
182
- } else {
183
- cell[0] = (cell[0] * cell[2] + p.x * k) / (cell[2] + k); // x
184
- cell[1] = (cell[1] * cell[2] + p.y * k) / (cell[2] + k); // y
185
- cell[2] += k; // cumulated intensity value
186
- }
187
- }
188
- }
189
-
190
- for (i = 0, len = grid.length; i < len; i++) {
191
- if (grid[i]) {
192
- for (j = 0, len2 = grid[i].length; j < len2; j++) {
193
- cell = grid[i][j];
194
- if (cell) {
195
- data.push([
196
- Math.round(cell[0]),
197
- Math.round(cell[1]),
198
- Math.min(cell[2], max)
199
- ]);
200
- }
201
- }
202
- }
203
- }
204
- // console.timeEnd('process');
205
-
206
- // console.time('draw ' + data.length);
207
- this._heat.data(data).draw(this.options["minOpacity"]);
208
- // console.timeEnd('draw ' + data.length);
209
-
210
- this._frame = null;
211
- }
212
-
213
- _animateZoom(e) {
214
- const scale = this._map.getZoomScale(e.zoom);
215
- const offset = this._map["_getCenterOffset"](e.center)._multiplyBy(-scale).subtract(this._map["_getMapPanePos"]());
216
-
217
- if (L.DomUtil.setTransform) {
218
- L.DomUtil.setTransform(this._canvas, offset, scale);
219
-
220
- } else {
221
- this._canvas.style[L.DomUtil.TRANSFORM] = (L.DomUtil as any).getTranslateString(offset) + " scale(" + scale + ")";
222
- }
223
- }
224
- }
1
+ import * as L from "leaflet";
2
+ import * as _simpleheat from "simpleheat";
3
+
4
+ const simpleheat = (window as any).simpleheat || (_simpleheat && _simpleheat.default) || _simpleheat;
5
+
6
+ /* Ported from https://github.com/Leaflet/Leaflet.heat
7
+ Changes:
8
+ * Ported to TypeScript
9
+ */
10
+
11
+ export class LeafletLayer2 extends L.Layer {
12
+ }
13
+
14
+ export class HeatLayer extends LeafletLayer2 {
15
+ _latlngs: any;
16
+ _heat: any;
17
+ _frame: any;
18
+ _canvas: any;
19
+
20
+ // options: {
21
+ // minOpacity: 0.05,
22
+ // maxZoom: 18,
23
+ // radius: 25,
24
+ // blur: 15,
25
+ // max: 1.0
26
+ // }
27
+
28
+ constructor(latlngs, options = {}) {
29
+ super(options);
30
+ this._latlngs = latlngs;
31
+ }
32
+
33
+ initialize(options) {
34
+ this.setOptions(options);
35
+ }
36
+
37
+ setLatLngs(latlngs) {
38
+ this._latlngs = latlngs;
39
+ return this.redraw();
40
+ }
41
+
42
+ addLatLng(latlng) {
43
+ this._latlngs.push(latlng);
44
+ return this.redraw();
45
+ }
46
+
47
+ setOptions(options) {
48
+ this.options = options;
49
+ if (this._heat) {
50
+ this._updateOptions();
51
+ }
52
+ return this.redraw();
53
+ }
54
+
55
+ redraw() {
56
+ if (this._heat && !this._frame && !this._map["_animating"]) {
57
+ this._frame = L.Util.requestAnimFrame(this._redraw, this);
58
+ }
59
+ return this;
60
+ }
61
+
62
+ onAdd(map): this {
63
+ this._map = map;
64
+
65
+ if (!this._canvas) {
66
+ this._initCanvas();
67
+ }
68
+
69
+ map._panes.overlayPane.appendChild(this._canvas);
70
+
71
+ map.on("moveend", this._reset, this);
72
+
73
+ if (map.options.zoomAnimation && L.Browser.any3d) {
74
+ map.on("zoomanim", this._animateZoom, this);
75
+ }
76
+
77
+ this._reset();
78
+ return this;
79
+ }
80
+
81
+ onRemove(map): this {
82
+ map.getPanes().overlayPane.removeChild(this._canvas);
83
+
84
+ map.off("moveend", this._reset, this);
85
+
86
+ if (map.options.zoomAnimation) {
87
+ map.off("zoomanim", this._animateZoom, this);
88
+ }
89
+ return this;
90
+ }
91
+
92
+ addTo(map) {
93
+ map.addLayer(this);
94
+ return this;
95
+ }
96
+
97
+ _initCanvas() {
98
+ const canvas: any = this._canvas = L.DomUtil.create("canvas", "leaflet-heatmap-layer leaflet-layer");
99
+
100
+ const originProp = L.DomUtil.testProp(["transformOrigin", "WebkitTransformOrigin", "msTransformOrigin"]);
101
+ canvas.style[originProp as string] = "50% 50%";
102
+
103
+ const size = this._map.getSize();
104
+ canvas.width = size.x;
105
+ canvas.height = size.y;
106
+
107
+ const animated = this._map.options.zoomAnimation && L.Browser.any3d;
108
+ L.DomUtil.addClass(canvas, "leaflet-zoom-" + (animated ? "animated" : "hide"));
109
+
110
+ this._heat = simpleheat(canvas);
111
+ this._updateOptions();
112
+ }
113
+
114
+ _updateOptions() {
115
+ this._heat.radius(this.options["radius"] || this._heat.defaultRadius, this.options["blur"]);
116
+
117
+ if (this.options["gradient"]) {
118
+ this._heat.gradient(this.options["gradient"]);
119
+ }
120
+ if (this.options["max"]) {
121
+ this._heat.max(this.options["max"]);
122
+ }
123
+ }
124
+
125
+ _reset() {
126
+ const topLeft = this._map.containerPointToLayerPoint([0, 0]);
127
+ L.DomUtil.setPosition(this._canvas, topLeft);
128
+
129
+ const size = this._map.getSize();
130
+
131
+ if (this._heat._width !== size.x) {
132
+ this._canvas.width = this._heat._width = size.x;
133
+ }
134
+ if (this._heat._height !== size.y) {
135
+ this._canvas.height = this._heat._height = size.y;
136
+ }
137
+
138
+ this._redraw();
139
+ }
140
+
141
+ _redraw() {
142
+ const data = [];
143
+ const r = this._heat._r;
144
+ const size = this._map.getSize();
145
+ const bounds = new L.Bounds(L.point([-r, -r]), size.add([r, r]));
146
+ const max = this.options["max"] === undefined ? 1 : this.options["max"];
147
+ const maxZoom = this.options["maxZoom"] === undefined ? this._map.getMaxZoom() : this.options["maxZoom"];
148
+ const v = 1 / Math.pow(2, Math.max(0, Math.min(maxZoom - this._map.getZoom(), 12)));
149
+ const cellSize = r / 2;
150
+ const grid = [];
151
+ const panePos = this._map["_getMapPanePos"]();
152
+ const offsetX = panePos.x % cellSize;
153
+ const offsetY = panePos.y % cellSize;
154
+ let i;
155
+ let len;
156
+ let p;
157
+ let cell;
158
+ let x;
159
+ let y;
160
+ let j;
161
+ let len2;
162
+ let k;
163
+
164
+ // console.time('process');
165
+ for (i = 0, len = this._latlngs.length; i < len; i++) {
166
+ p = this._map.latLngToContainerPoint(this._latlngs[i]);
167
+ if (bounds.contains(p)) {
168
+ x = Math.floor((p.x - offsetX) / cellSize) + 2;
169
+ y = Math.floor((p.y - offsetY) / cellSize) + 2;
170
+
171
+ const alt =
172
+ this._latlngs[i].alt !== undefined ? this._latlngs[i].alt :
173
+ this._latlngs[i][2] !== undefined ? +this._latlngs[i][2] : 1;
174
+ k = alt * v;
175
+
176
+ grid[y] = grid[y] || [];
177
+ cell = grid[y][x];
178
+
179
+ if (!cell) {
180
+ grid[y][x] = [p.x, p.y, k];
181
+
182
+ } else {
183
+ cell[0] = (cell[0] * cell[2] + p.x * k) / (cell[2] + k); // x
184
+ cell[1] = (cell[1] * cell[2] + p.y * k) / (cell[2] + k); // y
185
+ cell[2] += k; // cumulated intensity value
186
+ }
187
+ }
188
+ }
189
+
190
+ for (i = 0, len = grid.length; i < len; i++) {
191
+ if (grid[i]) {
192
+ for (j = 0, len2 = grid[i].length; j < len2; j++) {
193
+ cell = grid[i][j];
194
+ if (cell) {
195
+ data.push([
196
+ Math.round(cell[0]),
197
+ Math.round(cell[1]),
198
+ Math.min(cell[2], max)
199
+ ]);
200
+ }
201
+ }
202
+ }
203
+ }
204
+ // console.timeEnd('process');
205
+
206
+ // console.time('draw ' + data.length);
207
+ this._heat.data(data).draw(this.options["minOpacity"]);
208
+ // console.timeEnd('draw ' + data.length);
209
+
210
+ this._frame = null;
211
+ }
212
+
213
+ _animateZoom(e) {
214
+ const scale = this._map.getZoomScale(e.zoom);
215
+ const offset = this._map["_getCenterOffset"](e.center)._multiplyBy(-scale).subtract(this._map["_getMapPanePos"]());
216
+
217
+ if (L.DomUtil.setTransform) {
218
+ L.DomUtil.setTransform(this._canvas, offset, scale);
219
+
220
+ } else {
221
+ this._canvas.style[L.DomUtil.TRANSFORM] = (L.DomUtil as any).getTranslateString(offset) + " scale(" + scale + ")";
222
+ }
223
+ }
224
+ }