@hpcc-js/map 3.4.10 → 3.4.11

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 (96) 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 +7 -7
  15. package/src/CanvasPinLayer.ts +99 -99
  16. package/src/CanvasPins.ts +397 -397
  17. package/src/Choropleth.css +27 -27
  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 +16 -16
  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 +15 -15
  33. package/src/GeoHash.ts +139 -139
  34. package/src/Graph.css +10 -10
  35. package/src/Graph.ts +98 -98
  36. package/src/Graticule.css +13 -13
  37. package/src/Graticule.ts +97 -97
  38. package/src/Heat.css +2 -2
  39. package/src/Heat.ts +87 -87
  40. package/src/IChoropleth.ts +8 -8
  41. package/src/Layer.ts +99 -99
  42. package/src/Layered.css +19 -19
  43. package/src/Layered.ts +206 -206
  44. package/src/Lines.css +9 -9
  45. package/src/Lines.ts +78 -78
  46. package/src/OpenStreet.css +15 -15
  47. package/src/OpenStreet.ts +126 -126
  48. package/src/Pins.css +18 -18
  49. package/src/Pins.ts +350 -350
  50. package/src/Projection.ts +42 -42
  51. package/src/TestHeatMap.ts +8 -8
  52. package/src/TopoJSONChoropleth.ts +125 -125
  53. package/src/Utility.ts +484 -484
  54. package/src/__package__.ts +3 -3
  55. package/src/index.ts +33 -33
  56. package/src/leaflet/AlbersPR.ts +48 -48
  57. package/src/leaflet/Blank.ts +9 -9
  58. package/src/leaflet/Circles.ts +139 -139
  59. package/src/leaflet/ClusterCircles.css +26 -26
  60. package/src/leaflet/ClusterCircles.ts +88 -88
  61. package/src/leaflet/Countries.ts +43 -43
  62. package/src/leaflet/DrawLayer.ts +167 -167
  63. package/src/leaflet/FeatureLayer.ts +138 -138
  64. package/src/leaflet/GMap.ts +44 -44
  65. package/src/leaflet/HeatLayer.ts +77 -77
  66. package/src/leaflet/Icons.ts +60 -60
  67. package/src/leaflet/Leaflet.css +3 -3
  68. package/src/leaflet/Leaflet.ts +239 -239
  69. package/src/leaflet/MapBox.ts +35 -35
  70. package/src/leaflet/Markers.ts +109 -109
  71. package/src/leaflet/OpenStreet.ts +27 -27
  72. package/src/leaflet/Path.ts +138 -138
  73. package/src/leaflet/Pins.ts +73 -73
  74. package/src/leaflet/Polygons.ts +113 -113
  75. package/src/leaflet/Region.ts +138 -138
  76. package/src/leaflet/Text.ts +99 -99
  77. package/src/leaflet/TileLayer.ts +81 -81
  78. package/src/leaflet/TopoJSON.ts +146 -146
  79. package/src/leaflet/US.ts +15 -15
  80. package/src/leaflet/USCounties.ts +43 -43
  81. package/src/leaflet/USStates.ts +41 -41
  82. package/src/leaflet/World.css +3 -3
  83. package/src/leaflet/World.ts +172 -172
  84. package/src/leaflet/index.ts +18 -18
  85. package/src/leaflet/leaflet-shim.ts +18 -18
  86. package/src/leaflet/plugins/BeautifyIcon.css +44 -44
  87. package/src/leaflet/plugins/BeautifyIcon.ts +190 -190
  88. package/src/leaflet/plugins/BeutifyIcon.licence +20 -20
  89. package/src/leaflet/plugins/D3SvgOverlay.css +3 -3
  90. package/src/leaflet/plugins/D3SvgOverlay.licence +20 -20
  91. package/src/leaflet/plugins/D3SvgOverlay.ts +175 -175
  92. package/src/leaflet/plugins/HeatLayer.license +21 -21
  93. package/src/leaflet/plugins/HeatLayer.ts +224 -224
  94. package/src/leaflet/plugins/Leaflet.GoogleMutant.ts +424 -424
  95. package/src/leaflet/plugins/lru_map.ts +352 -352
  96. package/src/test.ts +114 -114
@@ -1,175 +1,175 @@
1
- import { geoPath as d3GeoPath, geoTransform as d3GeoTransform } from "d3-geo";
2
- import { select as d3Select } from "d3-selection";
3
- import * as L from "leaflet";
4
-
5
- import "./D3SvgOverlay.css";
6
-
7
- /* Ported from https://github.com/teralytics/Leaflet.D3SvgOverlay
8
- Changes:
9
- * Ported to TypeScript
10
- * Updated to work with d3 v4
11
- * Updated to work with Leaflet > 1.0
12
- * Fixed issue with metresPerPixel calculation
13
- * Update metresPerPixel on each draw call
14
- */
15
-
16
- export class LeafletLayer extends L.Layer {
17
- _rootGroup;
18
- }
19
-
20
- export type DrawCallback = (element, projection, zoom) => void;
21
-
22
- export class D3SvgOverlay extends LeafletLayer {
23
- private _svg;
24
- map;
25
- selection;
26
- projection;
27
- private _pixelOrigin;
28
- private _zoomDiff;
29
- private _zoom;
30
- private _scale;
31
- private _shift;
32
- private _wgsOrigin;
33
- private _wgsInitialShift;
34
-
35
- constructor(options = {}) {
36
- super();
37
- this._options(options);
38
- }
39
-
40
- svg() {
41
- return this._rootGroup;
42
- }
43
-
44
- private _drawCallback: DrawCallback;
45
- drawCallback(): DrawCallback;
46
- drawCallback(_: DrawCallback): this;
47
- drawCallback(_?: DrawCallback): DrawCallback | this {
48
- if (!arguments.length) return this._drawCallback;
49
- this._drawCallback = _;
50
- return this;
51
- }
52
-
53
- getBounds(): L.LatLngBounds {
54
- if (!this.selection || !this.projection) {
55
- return new L.LatLngBounds([-90, -180], [90, 180]);
56
- }
57
- const bbox = this.selection.node().getBBox();
58
- let sw;
59
- try {
60
- sw = this.projection.layerPointToLatLng(new L.Point(bbox.x, bbox.y + bbox.height));
61
- } catch (e) {
62
- sw = [-90, -180];
63
- }
64
- let ne;
65
- try {
66
- ne = this.projection.layerPointToLatLng(new L.Point(bbox.x + bbox.width, bbox.y));
67
- } catch (e) {
68
- ne = [90, 180];
69
- }
70
- return new L.LatLngBounds(sw, ne);
71
- }
72
-
73
- _undef(a) {
74
- return typeof a === "undefined";
75
- }
76
-
77
- _options(options) {
78
- if (this._undef(options)) {
79
- return this.options;
80
- }
81
- options.zoomHide = this._undef(options.zoomHide) ? false : options.zoomHide;
82
- options.zoomDraw = this._undef(options.zoomDraw) ? true : options.zoomDraw;
83
-
84
- return this.options = options;
85
- }
86
-
87
- draw() {
88
- if (!this.map || !this._drawCallback) return;
89
- this.projection.metresPerPixel = (40075016.686 * Math.abs(Math.cos(this.map.getCenter().lat * Math.PI / 180)) / Math.pow(2, this.map.getZoom() + 8)) * this.projection.scale;
90
- this._drawCallback(this.selection, this.projection, this.map.getZoom());
91
- }
92
-
93
- // Handler for "viewreset"-like events, updates scale and shift after the animation
94
- _zoomChange(evt) {
95
- const newZoom = this._undef(evt.zoom) ? this.map._zoom : evt.zoom; // "viewreset" event in Leaflet has not zoom/center parameters like zoomanim
96
- this._zoomDiff = newZoom - this._zoom;
97
- this._scale = Math.pow(2, this._zoomDiff);
98
- this.projection.scale = this._scale;
99
- this._shift = this.map.latLngToLayerPoint(this._wgsOrigin)._subtract(this._wgsInitialShift.multiplyBy(this._scale));
100
- const shift = ["translate(", this._shift.x, ",", this._shift.y, ") "];
101
- const scale = ["scale(", this._scale, ",", this._scale, ") "];
102
- this._rootGroup.attr("transform", shift.concat(scale).join(""));
103
-
104
- if (this.options["zoomDraw"]) { this.draw(); }
105
- }
106
-
107
- onAdd(map): this {
108
- this.map = map;
109
- const _layer = this;
110
-
111
- // SVG element
112
- this._svg = L.svg();
113
- map.addLayer(this._svg);
114
- this._rootGroup = d3Select(this._svg._rootGroup).classed("d3-overlay", true);
115
- this._rootGroup.classed("leaflet-zoom-hide", this.options["zoomDraw"]);
116
- this.selection = this._rootGroup;
117
-
118
- // Init shift/scale invariance helper values
119
- this._pixelOrigin = map.getPixelOrigin();
120
- this._wgsOrigin = L.latLng([0, 0]);
121
- this._wgsInitialShift = this.map.latLngToLayerPoint(this._wgsOrigin);
122
- this._zoom = this.map.getZoom();
123
- this._shift = L.point(0, 0);
124
- this._scale = 1;
125
-
126
- // Create projection object
127
- this.projection = {
128
- latLngToLayerPoint(latLng, zoom) {
129
- zoom = _layer._undef(zoom) ? _layer._zoom : zoom;
130
- const projectedPoint = _layer.map.project(L.latLng(latLng), zoom);
131
- return projectedPoint._subtract(_layer._pixelOrigin);
132
- },
133
- layerPointToLatLng(point, zoom) {
134
- zoom = _layer._undef(zoom) ? _layer._zoom : zoom;
135
- const projectedPoint = L.point(point).add(_layer._pixelOrigin);
136
- return _layer.map.unproject(projectedPoint, zoom);
137
- },
138
- unitsPerMeter: 256 * Math.pow(2, _layer._zoom) / 40075017,
139
- metresPerPixel: 40075016.686 * Math.abs(Math.cos(map.getCenter().lat * Math.PI / 180)) / Math.pow(2, map.getZoom() + 8),
140
- map: _layer.map,
141
- layer: _layer,
142
- scale: 1
143
- };
144
- this.projection._projectPoint = function (x, y) {
145
- const point = _layer.projection.latLngToLayerPoint(new L.LatLng(y, x));
146
- this.stream.point(point.x, point.y);
147
- };
148
- this.projection.pathFromGeojson = (d3GeoPath().projection(d3GeoTransform({ point: this.projection._projectPoint })));
149
-
150
- // Compatibility with v.1
151
- this.projection.latLngToLayerFloatPoint = this.projection.latLngToLayerPoint;
152
- this.projection.getZoom = this.map.getZoom.bind(this.map);
153
- this.projection.getBounds = this.map.getBounds.bind(this.map);
154
- this.selection = this._rootGroup;
155
-
156
- // Initial draw
157
- this.draw();
158
- return this;
159
- }
160
-
161
- // Leaflet 1.0
162
- getEvents() {
163
- return { zoomend: this._zoomChange, viewreset: this._zoomChange };
164
- }
165
-
166
- onRemove(map) {
167
- this._svg.remove();
168
- return this;
169
- }
170
-
171
- addTo(map) {
172
- map.addLayer(this);
173
- return this;
174
- }
175
- }
1
+ import { geoPath as d3GeoPath, geoTransform as d3GeoTransform } from "d3-geo";
2
+ import { select as d3Select } from "d3-selection";
3
+ import * as L from "leaflet";
4
+
5
+ import "./D3SvgOverlay.css";
6
+
7
+ /* Ported from https://github.com/teralytics/Leaflet.D3SvgOverlay
8
+ Changes:
9
+ * Ported to TypeScript
10
+ * Updated to work with d3 v4
11
+ * Updated to work with Leaflet > 1.0
12
+ * Fixed issue with metresPerPixel calculation
13
+ * Update metresPerPixel on each draw call
14
+ */
15
+
16
+ export class LeafletLayer extends L.Layer {
17
+ _rootGroup;
18
+ }
19
+
20
+ export type DrawCallback = (element, projection, zoom) => void;
21
+
22
+ export class D3SvgOverlay extends LeafletLayer {
23
+ private _svg;
24
+ map;
25
+ selection;
26
+ projection;
27
+ private _pixelOrigin;
28
+ private _zoomDiff;
29
+ private _zoom;
30
+ private _scale;
31
+ private _shift;
32
+ private _wgsOrigin;
33
+ private _wgsInitialShift;
34
+
35
+ constructor(options = {}) {
36
+ super();
37
+ this._options(options);
38
+ }
39
+
40
+ svg() {
41
+ return this._rootGroup;
42
+ }
43
+
44
+ private _drawCallback: DrawCallback;
45
+ drawCallback(): DrawCallback;
46
+ drawCallback(_: DrawCallback): this;
47
+ drawCallback(_?: DrawCallback): DrawCallback | this {
48
+ if (!arguments.length) return this._drawCallback;
49
+ this._drawCallback = _;
50
+ return this;
51
+ }
52
+
53
+ getBounds(): L.LatLngBounds {
54
+ if (!this.selection || !this.projection) {
55
+ return new L.LatLngBounds([-90, -180], [90, 180]);
56
+ }
57
+ const bbox = this.selection.node().getBBox();
58
+ let sw;
59
+ try {
60
+ sw = this.projection.layerPointToLatLng(new L.Point(bbox.x, bbox.y + bbox.height));
61
+ } catch (e) {
62
+ sw = [-90, -180];
63
+ }
64
+ let ne;
65
+ try {
66
+ ne = this.projection.layerPointToLatLng(new L.Point(bbox.x + bbox.width, bbox.y));
67
+ } catch (e) {
68
+ ne = [90, 180];
69
+ }
70
+ return new L.LatLngBounds(sw, ne);
71
+ }
72
+
73
+ _undef(a) {
74
+ return typeof a === "undefined";
75
+ }
76
+
77
+ _options(options) {
78
+ if (this._undef(options)) {
79
+ return this.options;
80
+ }
81
+ options.zoomHide = this._undef(options.zoomHide) ? false : options.zoomHide;
82
+ options.zoomDraw = this._undef(options.zoomDraw) ? true : options.zoomDraw;
83
+
84
+ return this.options = options;
85
+ }
86
+
87
+ draw() {
88
+ if (!this.map || !this._drawCallback) return;
89
+ this.projection.metresPerPixel = (40075016.686 * Math.abs(Math.cos(this.map.getCenter().lat * Math.PI / 180)) / Math.pow(2, this.map.getZoom() + 8)) * this.projection.scale;
90
+ this._drawCallback(this.selection, this.projection, this.map.getZoom());
91
+ }
92
+
93
+ // Handler for "viewreset"-like events, updates scale and shift after the animation
94
+ _zoomChange(evt) {
95
+ const newZoom = this._undef(evt.zoom) ? this.map._zoom : evt.zoom; // "viewreset" event in Leaflet has not zoom/center parameters like zoomanim
96
+ this._zoomDiff = newZoom - this._zoom;
97
+ this._scale = Math.pow(2, this._zoomDiff);
98
+ this.projection.scale = this._scale;
99
+ this._shift = this.map.latLngToLayerPoint(this._wgsOrigin)._subtract(this._wgsInitialShift.multiplyBy(this._scale));
100
+ const shift = ["translate(", this._shift.x, ",", this._shift.y, ") "];
101
+ const scale = ["scale(", this._scale, ",", this._scale, ") "];
102
+ this._rootGroup.attr("transform", shift.concat(scale).join(""));
103
+
104
+ if (this.options["zoomDraw"]) { this.draw(); }
105
+ }
106
+
107
+ onAdd(map): this {
108
+ this.map = map;
109
+ const _layer = this;
110
+
111
+ // SVG element
112
+ this._svg = L.svg();
113
+ map.addLayer(this._svg);
114
+ this._rootGroup = d3Select(this._svg._rootGroup).classed("d3-overlay", true);
115
+ this._rootGroup.classed("leaflet-zoom-hide", this.options["zoomDraw"]);
116
+ this.selection = this._rootGroup;
117
+
118
+ // Init shift/scale invariance helper values
119
+ this._pixelOrigin = map.getPixelOrigin();
120
+ this._wgsOrigin = L.latLng([0, 0]);
121
+ this._wgsInitialShift = this.map.latLngToLayerPoint(this._wgsOrigin);
122
+ this._zoom = this.map.getZoom();
123
+ this._shift = L.point(0, 0);
124
+ this._scale = 1;
125
+
126
+ // Create projection object
127
+ this.projection = {
128
+ latLngToLayerPoint(latLng, zoom) {
129
+ zoom = _layer._undef(zoom) ? _layer._zoom : zoom;
130
+ const projectedPoint = _layer.map.project(L.latLng(latLng), zoom);
131
+ return projectedPoint._subtract(_layer._pixelOrigin);
132
+ },
133
+ layerPointToLatLng(point, zoom) {
134
+ zoom = _layer._undef(zoom) ? _layer._zoom : zoom;
135
+ const projectedPoint = L.point(point).add(_layer._pixelOrigin);
136
+ return _layer.map.unproject(projectedPoint, zoom);
137
+ },
138
+ unitsPerMeter: 256 * Math.pow(2, _layer._zoom) / 40075017,
139
+ metresPerPixel: 40075016.686 * Math.abs(Math.cos(map.getCenter().lat * Math.PI / 180)) / Math.pow(2, map.getZoom() + 8),
140
+ map: _layer.map,
141
+ layer: _layer,
142
+ scale: 1
143
+ };
144
+ this.projection._projectPoint = function (x, y) {
145
+ const point = _layer.projection.latLngToLayerPoint(new L.LatLng(y, x));
146
+ this.stream.point(point.x, point.y);
147
+ };
148
+ this.projection.pathFromGeojson = (d3GeoPath().projection(d3GeoTransform({ point: this.projection._projectPoint })));
149
+
150
+ // Compatibility with v.1
151
+ this.projection.latLngToLayerFloatPoint = this.projection.latLngToLayerPoint;
152
+ this.projection.getZoom = this.map.getZoom.bind(this.map);
153
+ this.projection.getBounds = this.map.getBounds.bind(this.map);
154
+ this.selection = this._rootGroup;
155
+
156
+ // Initial draw
157
+ this.draw();
158
+ return this;
159
+ }
160
+
161
+ // Leaflet 1.0
162
+ getEvents() {
163
+ return { zoomend: this._zoomChange, viewreset: this._zoomChange };
164
+ }
165
+
166
+ onRemove(map) {
167
+ this._svg.remove();
168
+ return this;
169
+ }
170
+
171
+ addTo(map) {
172
+ map.addLayer(this);
173
+ return this;
174
+ }
175
+ }
@@ -1,22 +1,22 @@
1
- Copyright (c) 2014, Vladimir Agafonkin
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are
5
- permitted provided that the following conditions are met:
6
-
7
- 1. Redistributions of source code must retain the above copyright notice, this list of
8
- conditions and the following disclaimer.
9
-
10
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
- of conditions and the following disclaimer in the documentation and/or other materials
12
- provided with the distribution.
13
-
14
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
15
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
17
- COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
21
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1
+ Copyright (c) 2014, Vladimir Agafonkin
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are
5
+ permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ of conditions and the following disclaimer in the documentation and/or other materials
12
+ provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
15
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
17
+ COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
21
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
22
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.