@hpcc-js/map 3.5.1 → 3.5.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.
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 +9 -9
  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
  96. package/types/Layered.d.ts +1 -1
package/src/Pins.ts CHANGED
@@ -1,350 +1,350 @@
1
- import { Platform, Utility } from "@hpcc-js/common";
2
- import { select as d3Select } from "d3-selection";
3
- import { Layer } from "./Layer.ts";
4
- import * as MapUtility from "./Utility.ts";
5
-
6
- import "../src/Pins.css";
7
-
8
- export class Pins extends Layer {
9
- _geohash;
10
- _pinsTransform;
11
- pinsPaths;
12
-
13
- constructor() {
14
- super();
15
- Utility.SimpleSelectionMixin.call(this);
16
- this._geohash = new MapUtility.Geohash();
17
- }
18
-
19
- pinsData() {
20
- const geohashField = this._db.fieldByLabel(this.geohashColumn());
21
- const tooltipField = this._db.fieldByLabel(this.tooltipColumn());
22
- const latField = this._db.fieldByLabel(this.latColumn());
23
- const longField = this._db.fieldByLabel(this.longColumn());
24
- const context = this;
25
- return this.data().filter(function (row) {
26
- const lat = latField ? row[latField.idx] : row[0];
27
- const long = longField ? row[longField.idx] : row[1];
28
- if (context.omitNullLatLong() && lat === 0 && long === 0) {
29
- return false;
30
- }
31
- return true;
32
- }).map(function (row, idx) {
33
- const lat = latField ? row[latField.idx] : row[0];
34
- const long = longField ? row[longField.idx] : row[1];
35
- const retVal = {
36
- idx,
37
- lat,
38
- long,
39
- ext: row[2] instanceof Object ? row[2] : {},
40
- origRow: row
41
- };
42
- if (geohashField) {
43
- try {
44
- const pos = this._geohash.bounds(row[geohashField.idx]);
45
- retVal.lat = (pos.ne.lat + pos.sw.lat) / 2;
46
- retVal.long = (pos.ne.lon + pos.sw.lon) / 2;
47
- } catch (e) {
48
- }
49
- }
50
- if (tooltipField) {
51
- retVal.ext.tooltip = row[tooltipField.idx];
52
- }
53
- return retVal;
54
- }, this);
55
- }
56
-
57
- layerEnter(base, svgElement, domElement) {
58
- Layer.prototype.layerEnter.apply(this, arguments);
59
-
60
- this._pinsTransform = svgElement;
61
- this._selection.widgetElement(this._pinsTransform);
62
- this.pinsPaths = d3Select(null);
63
- this.tooltipHTML(function (d) {
64
- return d.ext.tooltip === undefined ? "" : d.ext.tooltip;
65
- });
66
- }
67
-
68
- layerUpdate(base) {
69
- Layer.prototype.layerUpdate.apply(this, arguments);
70
-
71
- this._pinsTransform
72
- .style("opacity", this.opacity())
73
- ;
74
-
75
- this.pinsPaths = this._pinsTransform.selectAll(".pin").data(this.visible() ? this.pinsData() : [], d => d.idx);
76
- const context = this;
77
- const updatesPaths = this.pinsPaths.enter().append("g")
78
- .attr("class", "pin")
79
- .call(this._selection.enter.bind(this._selection))
80
- .on("click", function (d) {
81
- context.click(context.rowToObj(d.origRow), "geohash", context._selection.selected(this));
82
- })
83
- .on("dblclick", function (d) {
84
- context.dblclick(context.rowToObj(d.origRow), "geohash", context._selection.selected(this));
85
- })
86
- .on("mouseover", function (d) {
87
- if (!Platform.isIE) {
88
- this.parentNode.appendChild(this);
89
- }
90
- })
91
- .on("mouseout.tooltip", function (d) {
92
- if (d.ext && d.ext.tooltip) {
93
- context.tooltip.hide.apply(this, arguments);
94
- }
95
- })
96
- .on("mousemove.tooltip", function (d) {
97
- if (d.ext && d.ext.tooltip) {
98
- context.tooltip.show.apply(this, arguments);
99
- }
100
- })
101
- .each(function (d) {
102
- const element = d3Select(this);
103
- element.append("path")
104
- .attr("class", "data")
105
- ;
106
- element.append("text")
107
- .attr("text-anchor", "middle")
108
- ;
109
- }).merge(this.pinsPaths);
110
- updatesPaths.selectAll("text")
111
- .style("stroke", this.fontColor())
112
- .style("fill", this.fontColor())
113
- .style("font-size", this.fontSize())
114
- .style("font-family", this.fontFamily())
115
- .style("dominant-baseline", this.textBaseline())
116
- .attr("dx", 0)
117
- .attr("dy", this.pinTextDY())
118
- .text(function (d) {
119
- return d.ext && d.ext.text ? d.ext.text : "";
120
- });
121
- const svgPath = this.svgPinPath();
122
- updatesPaths.selectAll("path.data")
123
- .attr("d", svgPath)
124
- .attr("stroke-width", this.strokeWidth() + "px")
125
- .style("display", function (d) {
126
- const pos = base.project(d.lat, d.long);
127
- if (!pos) {
128
- return "none";
129
- }
130
- return null;
131
- })
132
- .style("stroke", function (d) {
133
- return d.ext && d.ext.strokeColor ? d.ext.strokeColor : context.strokeColor();
134
- })
135
- .style("fill", function (d) {
136
- return d.ext && d.ext.fillColor ? d.ext.fillColor : context.fillColor();
137
- })
138
- ;
139
- this.pinsPaths.exit().remove();
140
- }
141
-
142
- layerZoomed(base) {
143
- Layer.prototype.layerZoomed.apply(this, arguments);
144
- this.pinsPaths
145
- .attr("transform", function (d) {
146
- let pos = base.project(d.lat, d.long);
147
- if (!pos) {
148
- pos = [0, 0];
149
- }
150
- return "translate(" + pos[0] + ", " + pos[1] + ")scale(" + (1 / base.zoomScale()) + ")";
151
- })
152
- ;
153
- }
154
-
155
- pinTextDY() {
156
- switch (this.pinType()) {
157
- case "pin":
158
- case "rectangle-pin":
159
- return -this.arrowHeight();
160
- case "circle":
161
- case "rectangle":
162
- return 0;
163
- }
164
- }
165
- svgPinPath() {
166
- switch (this.pinType()) {
167
- case "pin":
168
- return this.circlePinPath();
169
- case "circle":
170
- return this.circlePath();
171
- case "rectangle":
172
- return this.rectanglePath();
173
- case "rectangle-pin":
174
- return this.rectanglePinPath();
175
- }
176
- }
177
-
178
- rectanglePinPath() {
179
- const width = this.pinWidth();
180
- const height = this.pinHeight();
181
- const radius = this.cornerRadius();
182
- const arrow_h = this.arrowHeight();
183
- const arrow_w = this.arrowWidth();
184
- const x = 0 - width / 2;
185
- const y = 0 - height + radius;
186
- const arrow_b = (width - radius * 2 - arrow_w) / 2;
187
- return "M" + x + "," + y +
188
- "a" + -radius + "," + -radius + " 0 0 1 " + radius + "," + -radius +
189
- "h" + (width + -radius * 2) +
190
- "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius +
191
- "v" + (height + -radius * 2) +
192
- "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius +
193
- "h" + -arrow_b +
194
- "l" + -arrow_w / 2 + "," + arrow_h +
195
- "l" + -arrow_w / 2 + "," + -arrow_h +
196
- "h" + -arrow_b +
197
- "a" + -radius + "," + -radius + " 0 0 1 " + -radius + "," + -radius +
198
- "z";
199
- }
200
- rectanglePath() {
201
- const width = this.pinWidth();
202
- const height = this.pinHeight();
203
- const radius = this.cornerRadius();
204
- const x = -width / 2;
205
- let y = -height / 2;
206
- y += radius;
207
- return "M" + x + "," + y +
208
- "a" + -radius + "," + -radius + " 0 0 1 " + radius + "," + -radius +
209
- "h" + (width + -radius * 2) +
210
- "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius +
211
- "v" + (height + -radius * 2) +
212
- "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius +
213
- "h" + (-width + radius * 2) +
214
- "a" + -radius + "," + -radius + " 0 0 1 " + -radius + "," + -radius +
215
- "z";
216
- }
217
- circlePinPath() {
218
- const arrow_h = this.arrowHeight();
219
- const arrow_w = this.arrowWidth();
220
- const x = 0 - arrow_w / 2;
221
- const y = 0 - arrow_h;
222
- const bezier_x = arrow_w / 2;
223
- const bezier_y = arrow_h;
224
- const c_dx1 = -bezier_x;
225
- const c_dy1 = -bezier_y;
226
- const c_dx2 = arrow_w + bezier_x;
227
- const c_dy2 = c_dy1;
228
- const c_dx = arrow_w;
229
- const c_dy = 0;
230
- return "M" + x + "," + y +
231
- "c" + c_dx1 + " " + c_dy1 + ", " + c_dx2 + " " + c_dy2 + ", " + c_dx + " " + c_dy +
232
- "l" + -arrow_w / 2 + "," + arrow_h +
233
- "l" + -arrow_w / 2 + "," + -arrow_h +
234
- "z";
235
- }
236
-
237
- circlePath() {
238
- const radius = +this.pinRadius();
239
- return `M 0, 0 m ${-radius}, 0 a ${radius},${radius} 0 1,0 ${radius * 2},0 a ${radius},${radius} 0 1,0 ${-radius * 2},0`;
240
- }
241
-
242
- // Events ---
243
- click(row, column, selected) {
244
- }
245
-
246
- dblclick(row, column, selected) {
247
- }
248
- }
249
- Pins.prototype._class += " map_Pins";
250
- Pins.prototype.mixin(Utility.SimpleSelectionMixin);
251
-
252
- export interface Pins {
253
- // Simple Selection ---
254
- _selection;
255
-
256
- // Properties ---
257
- latColumn(): string;
258
- latColumn(_: string): this;
259
- latColumn_exists(): boolean;
260
- longColumn(): string;
261
- longColumn(_: string): this;
262
- longColumn_exists(): boolean;
263
- geohashColumn(): string;
264
- geohashColumn(_: string): this;
265
- geohashColumn_exists(): boolean;
266
- tooltipColumn(): string;
267
- tooltipColumn(_: string): this;
268
- tooltipColumn_exists(): boolean;
269
- opacity(): number;
270
- opacity(_: number): this;
271
- opacity_exists(): boolean;
272
- fillColor(): string;
273
- fillColor(_: string): this;
274
- fillColor_exists(): boolean;
275
- omitNullLatLong(): boolean;
276
- omitNullLatLong(_: boolean): this;
277
- omitNullLatLong_exists(): boolean;
278
-
279
- strokeWidth(): number;
280
- strokeWidth(_: number): this;
281
- strokeWidth_exists(): boolean;
282
- strokeColor(): string;
283
- strokeColor(_: string): this;
284
- strokeColor_exists(): boolean;
285
-
286
- fontSize(): number;
287
- fontSize(_: number): this;
288
- fontSize_exists(): boolean;
289
- fontFamily(): string;
290
- fontFamily(_: string): this;
291
- fontFamily_exists(): boolean;
292
- fontColor(): string;
293
- fontColor(_: string): this;
294
- fontColor_exists(): boolean;
295
-
296
- pinType(): string;
297
- pinType(_: string): this;
298
- pinType_exists(): boolean;
299
- arrowWidth(): number;
300
- arrowWidth(_: number): this;
301
- arrowWidth_exists(): boolean;
302
- arrowHeight(): number;
303
- arrowHeight(_: number): this;
304
- arrowHeight_exists(): boolean;
305
-
306
- pinWidth(): number;
307
- pinWidth(_: number): this;
308
- pinWidth_exists(): boolean;
309
- pinHeight(): number;
310
- pinHeight(_: number): this;
311
- pinHeight_exists(): boolean;
312
- cornerRadius(): number;
313
- cornerRadius(_: number): this;
314
- cornerRadius_exists(): boolean;
315
-
316
- pinRadius(): number;
317
- pinRadius(_: number): this;
318
- pinRadius_exists(): boolean;
319
-
320
- textBaseline(): string;
321
- textBaseline(_: string): this;
322
- textBaseline_exists(): boolean;
323
- }
324
-
325
- Pins.prototype.publish("geohashColumn", null, "set", "Geohash column", function () { return this.columns(); }, { optional: true });
326
- Pins.prototype.publish("tooltipColumn", null, "set", "Tooltip column", function () { return this.columns(); }, { optional: true });
327
- Pins.prototype.publish("latColumn", null, "set", "Latitude column", function () { return this.columns(); }, { optional: true });
328
- Pins.prototype.publish("longColumn", null, "set", "Longitude column", function () { return this.columns(); }, { optional: true });
329
- Pins.prototype.publish("opacity", 1.0, "number", "Opacity", null, { tags: ["Advanced"] });
330
- Pins.prototype.publish("fillColor", "#00FFDD", "html-color", "Pin Color", null, { optional: true });
331
- Pins.prototype.publish("omitNullLatLong", false, "boolean", "Remove lat=0,lng=0 from pinsData", null, { tags: ["Basic"] });
332
-
333
- Pins.prototype.publish("strokeWidth", 0.5, "number", "Pin Border Thickness (pixels)", null, { tags: ["Basic"] });
334
- Pins.prototype.publish("strokeColor", "", "html-color", "Pin Border Color", null, { optional: true });
335
-
336
- Pins.prototype.publish("fontSize", 18, "number", "Font Size", null, { tags: ["Basic", "Shared"] });
337
- Pins.prototype.publish("fontFamily", "Verdana", "string", "Font Name", null, { tags: ["Basic", "Shared", "Shared"] });
338
- Pins.prototype.publish("fontColor", "#000000", "html-color", "Font Color", null, { tags: ["Basic", "Shared"] });
339
-
340
- Pins.prototype.publish("pinType", "pin", "set", "Pin Type", ["pin", "circle", "rectangle", "rectangle-pin"], { tags: ["Basic"] });
341
- Pins.prototype.publish("arrowWidth", 8, "number", "Pin arrow width (pixels)", null, { tags: ["Basic"], disable: w => ["pin", "rectangle-pin"].indexOf(w.pinType()) === -1 });
342
- Pins.prototype.publish("arrowHeight", 12, "number", "Pin arrow height (pixels)", null, { tags: ["Basic"], disable: w => ["pin", "rectangle-pin"].indexOf(w.pinType()) === -1 });
343
-
344
- Pins.prototype.publish("pinWidth", 20, "number", "Width of pin (pixels)", null, { tags: ["Basic"], disable: w => ["rectangle", "rectangle-pin"].indexOf(w.pinType()) === -1 });
345
- Pins.prototype.publish("pinHeight", 20, "number", "Height of pin (pixels) (not including arrow)", null, { tags: ["Basic"], disable: w => ["rectangle", "rectangle-pin"].indexOf(w.pinType()) === -1 });
346
- Pins.prototype.publish("cornerRadius", 10, "number", "Radius of rectangular pin corners (pixels)", null, { tags: ["Basic"], disable: w => ["rectangle", "rectangle-pin"].indexOf(w.pinType()) === -1 });
347
-
348
- Pins.prototype.publish("pinRadius", 12, "number", "Radius of circle (pixels)", null, { tags: ["Basic"], disable: w => w.pinType() !== "circle" });
349
-
350
- Pins.prototype.publish("textBaseline", "central", "set", "Pin text vertical alignment", ["auto", "use-script", "no-change", "reset-size", "ideographic", "alphabetic", "hanging", "mathematical", "central", "middle", "text-after-edge", "text-before-edge", "inherit"], { tags: ["Basic"] });
1
+ import { Platform, Utility } from "@hpcc-js/common";
2
+ import { select as d3Select } from "d3-selection";
3
+ import { Layer } from "./Layer.ts";
4
+ import * as MapUtility from "./Utility.ts";
5
+
6
+ import "../src/Pins.css";
7
+
8
+ export class Pins extends Layer {
9
+ _geohash;
10
+ _pinsTransform;
11
+ pinsPaths;
12
+
13
+ constructor() {
14
+ super();
15
+ Utility.SimpleSelectionMixin.call(this);
16
+ this._geohash = new MapUtility.Geohash();
17
+ }
18
+
19
+ pinsData() {
20
+ const geohashField = this._db.fieldByLabel(this.geohashColumn());
21
+ const tooltipField = this._db.fieldByLabel(this.tooltipColumn());
22
+ const latField = this._db.fieldByLabel(this.latColumn());
23
+ const longField = this._db.fieldByLabel(this.longColumn());
24
+ const context = this;
25
+ return this.data().filter(function (row) {
26
+ const lat = latField ? row[latField.idx] : row[0];
27
+ const long = longField ? row[longField.idx] : row[1];
28
+ if (context.omitNullLatLong() && lat === 0 && long === 0) {
29
+ return false;
30
+ }
31
+ return true;
32
+ }).map(function (row, idx) {
33
+ const lat = latField ? row[latField.idx] : row[0];
34
+ const long = longField ? row[longField.idx] : row[1];
35
+ const retVal = {
36
+ idx,
37
+ lat,
38
+ long,
39
+ ext: row[2] instanceof Object ? row[2] : {},
40
+ origRow: row
41
+ };
42
+ if (geohashField) {
43
+ try {
44
+ const pos = this._geohash.bounds(row[geohashField.idx]);
45
+ retVal.lat = (pos.ne.lat + pos.sw.lat) / 2;
46
+ retVal.long = (pos.ne.lon + pos.sw.lon) / 2;
47
+ } catch (e) {
48
+ }
49
+ }
50
+ if (tooltipField) {
51
+ retVal.ext.tooltip = row[tooltipField.idx];
52
+ }
53
+ return retVal;
54
+ }, this);
55
+ }
56
+
57
+ layerEnter(base, svgElement, domElement) {
58
+ Layer.prototype.layerEnter.apply(this, arguments);
59
+
60
+ this._pinsTransform = svgElement;
61
+ this._selection.widgetElement(this._pinsTransform);
62
+ this.pinsPaths = d3Select(null);
63
+ this.tooltipHTML(function (d) {
64
+ return d.ext.tooltip === undefined ? "" : d.ext.tooltip;
65
+ });
66
+ }
67
+
68
+ layerUpdate(base) {
69
+ Layer.prototype.layerUpdate.apply(this, arguments);
70
+
71
+ this._pinsTransform
72
+ .style("opacity", this.opacity())
73
+ ;
74
+
75
+ this.pinsPaths = this._pinsTransform.selectAll(".pin").data(this.visible() ? this.pinsData() : [], d => d.idx);
76
+ const context = this;
77
+ const updatesPaths = this.pinsPaths.enter().append("g")
78
+ .attr("class", "pin")
79
+ .call(this._selection.enter.bind(this._selection))
80
+ .on("click", function (d) {
81
+ context.click(context.rowToObj(d.origRow), "geohash", context._selection.selected(this));
82
+ })
83
+ .on("dblclick", function (d) {
84
+ context.dblclick(context.rowToObj(d.origRow), "geohash", context._selection.selected(this));
85
+ })
86
+ .on("mouseover", function (d) {
87
+ if (!Platform.isIE) {
88
+ this.parentNode.appendChild(this);
89
+ }
90
+ })
91
+ .on("mouseout.tooltip", function (d) {
92
+ if (d.ext && d.ext.tooltip) {
93
+ context.tooltip.hide.apply(this, arguments);
94
+ }
95
+ })
96
+ .on("mousemove.tooltip", function (d) {
97
+ if (d.ext && d.ext.tooltip) {
98
+ context.tooltip.show.apply(this, arguments);
99
+ }
100
+ })
101
+ .each(function (d) {
102
+ const element = d3Select(this);
103
+ element.append("path")
104
+ .attr("class", "data")
105
+ ;
106
+ element.append("text")
107
+ .attr("text-anchor", "middle")
108
+ ;
109
+ }).merge(this.pinsPaths);
110
+ updatesPaths.selectAll("text")
111
+ .style("stroke", this.fontColor())
112
+ .style("fill", this.fontColor())
113
+ .style("font-size", this.fontSize())
114
+ .style("font-family", this.fontFamily())
115
+ .style("dominant-baseline", this.textBaseline())
116
+ .attr("dx", 0)
117
+ .attr("dy", this.pinTextDY())
118
+ .text(function (d) {
119
+ return d.ext && d.ext.text ? d.ext.text : "";
120
+ });
121
+ const svgPath = this.svgPinPath();
122
+ updatesPaths.selectAll("path.data")
123
+ .attr("d", svgPath)
124
+ .attr("stroke-width", this.strokeWidth() + "px")
125
+ .style("display", function (d) {
126
+ const pos = base.project(d.lat, d.long);
127
+ if (!pos) {
128
+ return "none";
129
+ }
130
+ return null;
131
+ })
132
+ .style("stroke", function (d) {
133
+ return d.ext && d.ext.strokeColor ? d.ext.strokeColor : context.strokeColor();
134
+ })
135
+ .style("fill", function (d) {
136
+ return d.ext && d.ext.fillColor ? d.ext.fillColor : context.fillColor();
137
+ })
138
+ ;
139
+ this.pinsPaths.exit().remove();
140
+ }
141
+
142
+ layerZoomed(base) {
143
+ Layer.prototype.layerZoomed.apply(this, arguments);
144
+ this.pinsPaths
145
+ .attr("transform", function (d) {
146
+ let pos = base.project(d.lat, d.long);
147
+ if (!pos) {
148
+ pos = [0, 0];
149
+ }
150
+ return "translate(" + pos[0] + ", " + pos[1] + ")scale(" + (1 / base.zoomScale()) + ")";
151
+ })
152
+ ;
153
+ }
154
+
155
+ pinTextDY() {
156
+ switch (this.pinType()) {
157
+ case "pin":
158
+ case "rectangle-pin":
159
+ return -this.arrowHeight();
160
+ case "circle":
161
+ case "rectangle":
162
+ return 0;
163
+ }
164
+ }
165
+ svgPinPath() {
166
+ switch (this.pinType()) {
167
+ case "pin":
168
+ return this.circlePinPath();
169
+ case "circle":
170
+ return this.circlePath();
171
+ case "rectangle":
172
+ return this.rectanglePath();
173
+ case "rectangle-pin":
174
+ return this.rectanglePinPath();
175
+ }
176
+ }
177
+
178
+ rectanglePinPath() {
179
+ const width = this.pinWidth();
180
+ const height = this.pinHeight();
181
+ const radius = this.cornerRadius();
182
+ const arrow_h = this.arrowHeight();
183
+ const arrow_w = this.arrowWidth();
184
+ const x = 0 - width / 2;
185
+ const y = 0 - height + radius;
186
+ const arrow_b = (width - radius * 2 - arrow_w) / 2;
187
+ return "M" + x + "," + y +
188
+ "a" + -radius + "," + -radius + " 0 0 1 " + radius + "," + -radius +
189
+ "h" + (width + -radius * 2) +
190
+ "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius +
191
+ "v" + (height + -radius * 2) +
192
+ "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius +
193
+ "h" + -arrow_b +
194
+ "l" + -arrow_w / 2 + "," + arrow_h +
195
+ "l" + -arrow_w / 2 + "," + -arrow_h +
196
+ "h" + -arrow_b +
197
+ "a" + -radius + "," + -radius + " 0 0 1 " + -radius + "," + -radius +
198
+ "z";
199
+ }
200
+ rectanglePath() {
201
+ const width = this.pinWidth();
202
+ const height = this.pinHeight();
203
+ const radius = this.cornerRadius();
204
+ const x = -width / 2;
205
+ let y = -height / 2;
206
+ y += radius;
207
+ return "M" + x + "," + y +
208
+ "a" + -radius + "," + -radius + " 0 0 1 " + radius + "," + -radius +
209
+ "h" + (width + -radius * 2) +
210
+ "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius +
211
+ "v" + (height + -radius * 2) +
212
+ "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius +
213
+ "h" + (-width + radius * 2) +
214
+ "a" + -radius + "," + -radius + " 0 0 1 " + -radius + "," + -radius +
215
+ "z";
216
+ }
217
+ circlePinPath() {
218
+ const arrow_h = this.arrowHeight();
219
+ const arrow_w = this.arrowWidth();
220
+ const x = 0 - arrow_w / 2;
221
+ const y = 0 - arrow_h;
222
+ const bezier_x = arrow_w / 2;
223
+ const bezier_y = arrow_h;
224
+ const c_dx1 = -bezier_x;
225
+ const c_dy1 = -bezier_y;
226
+ const c_dx2 = arrow_w + bezier_x;
227
+ const c_dy2 = c_dy1;
228
+ const c_dx = arrow_w;
229
+ const c_dy = 0;
230
+ return "M" + x + "," + y +
231
+ "c" + c_dx1 + " " + c_dy1 + ", " + c_dx2 + " " + c_dy2 + ", " + c_dx + " " + c_dy +
232
+ "l" + -arrow_w / 2 + "," + arrow_h +
233
+ "l" + -arrow_w / 2 + "," + -arrow_h +
234
+ "z";
235
+ }
236
+
237
+ circlePath() {
238
+ const radius = +this.pinRadius();
239
+ return `M 0, 0 m ${-radius}, 0 a ${radius},${radius} 0 1,0 ${radius * 2},0 a ${radius},${radius} 0 1,0 ${-radius * 2},0`;
240
+ }
241
+
242
+ // Events ---
243
+ click(row, column, selected) {
244
+ }
245
+
246
+ dblclick(row, column, selected) {
247
+ }
248
+ }
249
+ Pins.prototype._class += " map_Pins";
250
+ Pins.prototype.mixin(Utility.SimpleSelectionMixin);
251
+
252
+ export interface Pins {
253
+ // Simple Selection ---
254
+ _selection;
255
+
256
+ // Properties ---
257
+ latColumn(): string;
258
+ latColumn(_: string): this;
259
+ latColumn_exists(): boolean;
260
+ longColumn(): string;
261
+ longColumn(_: string): this;
262
+ longColumn_exists(): boolean;
263
+ geohashColumn(): string;
264
+ geohashColumn(_: string): this;
265
+ geohashColumn_exists(): boolean;
266
+ tooltipColumn(): string;
267
+ tooltipColumn(_: string): this;
268
+ tooltipColumn_exists(): boolean;
269
+ opacity(): number;
270
+ opacity(_: number): this;
271
+ opacity_exists(): boolean;
272
+ fillColor(): string;
273
+ fillColor(_: string): this;
274
+ fillColor_exists(): boolean;
275
+ omitNullLatLong(): boolean;
276
+ omitNullLatLong(_: boolean): this;
277
+ omitNullLatLong_exists(): boolean;
278
+
279
+ strokeWidth(): number;
280
+ strokeWidth(_: number): this;
281
+ strokeWidth_exists(): boolean;
282
+ strokeColor(): string;
283
+ strokeColor(_: string): this;
284
+ strokeColor_exists(): boolean;
285
+
286
+ fontSize(): number;
287
+ fontSize(_: number): this;
288
+ fontSize_exists(): boolean;
289
+ fontFamily(): string;
290
+ fontFamily(_: string): this;
291
+ fontFamily_exists(): boolean;
292
+ fontColor(): string;
293
+ fontColor(_: string): this;
294
+ fontColor_exists(): boolean;
295
+
296
+ pinType(): string;
297
+ pinType(_: string): this;
298
+ pinType_exists(): boolean;
299
+ arrowWidth(): number;
300
+ arrowWidth(_: number): this;
301
+ arrowWidth_exists(): boolean;
302
+ arrowHeight(): number;
303
+ arrowHeight(_: number): this;
304
+ arrowHeight_exists(): boolean;
305
+
306
+ pinWidth(): number;
307
+ pinWidth(_: number): this;
308
+ pinWidth_exists(): boolean;
309
+ pinHeight(): number;
310
+ pinHeight(_: number): this;
311
+ pinHeight_exists(): boolean;
312
+ cornerRadius(): number;
313
+ cornerRadius(_: number): this;
314
+ cornerRadius_exists(): boolean;
315
+
316
+ pinRadius(): number;
317
+ pinRadius(_: number): this;
318
+ pinRadius_exists(): boolean;
319
+
320
+ textBaseline(): string;
321
+ textBaseline(_: string): this;
322
+ textBaseline_exists(): boolean;
323
+ }
324
+
325
+ Pins.prototype.publish("geohashColumn", null, "set", "Geohash column", function () { return this.columns(); }, { optional: true });
326
+ Pins.prototype.publish("tooltipColumn", null, "set", "Tooltip column", function () { return this.columns(); }, { optional: true });
327
+ Pins.prototype.publish("latColumn", null, "set", "Latitude column", function () { return this.columns(); }, { optional: true });
328
+ Pins.prototype.publish("longColumn", null, "set", "Longitude column", function () { return this.columns(); }, { optional: true });
329
+ Pins.prototype.publish("opacity", 1.0, "number", "Opacity", null, { tags: ["Advanced"] });
330
+ Pins.prototype.publish("fillColor", "#00FFDD", "html-color", "Pin Color", null, { optional: true });
331
+ Pins.prototype.publish("omitNullLatLong", false, "boolean", "Remove lat=0,lng=0 from pinsData", null, { tags: ["Basic"] });
332
+
333
+ Pins.prototype.publish("strokeWidth", 0.5, "number", "Pin Border Thickness (pixels)", null, { tags: ["Basic"] });
334
+ Pins.prototype.publish("strokeColor", "", "html-color", "Pin Border Color", null, { optional: true });
335
+
336
+ Pins.prototype.publish("fontSize", 18, "number", "Font Size", null, { tags: ["Basic", "Shared"] });
337
+ Pins.prototype.publish("fontFamily", "Verdana", "string", "Font Name", null, { tags: ["Basic", "Shared", "Shared"] });
338
+ Pins.prototype.publish("fontColor", "#000000", "html-color", "Font Color", null, { tags: ["Basic", "Shared"] });
339
+
340
+ Pins.prototype.publish("pinType", "pin", "set", "Pin Type", ["pin", "circle", "rectangle", "rectangle-pin"], { tags: ["Basic"] });
341
+ Pins.prototype.publish("arrowWidth", 8, "number", "Pin arrow width (pixels)", null, { tags: ["Basic"], disable: w => ["pin", "rectangle-pin"].indexOf(w.pinType()) === -1 });
342
+ Pins.prototype.publish("arrowHeight", 12, "number", "Pin arrow height (pixels)", null, { tags: ["Basic"], disable: w => ["pin", "rectangle-pin"].indexOf(w.pinType()) === -1 });
343
+
344
+ Pins.prototype.publish("pinWidth", 20, "number", "Width of pin (pixels)", null, { tags: ["Basic"], disable: w => ["rectangle", "rectangle-pin"].indexOf(w.pinType()) === -1 });
345
+ Pins.prototype.publish("pinHeight", 20, "number", "Height of pin (pixels) (not including arrow)", null, { tags: ["Basic"], disable: w => ["rectangle", "rectangle-pin"].indexOf(w.pinType()) === -1 });
346
+ Pins.prototype.publish("cornerRadius", 10, "number", "Radius of rectangular pin corners (pixels)", null, { tags: ["Basic"], disable: w => ["rectangle", "rectangle-pin"].indexOf(w.pinType()) === -1 });
347
+
348
+ Pins.prototype.publish("pinRadius", 12, "number", "Radius of circle (pixels)", null, { tags: ["Basic"], disable: w => w.pinType() !== "circle" });
349
+
350
+ Pins.prototype.publish("textBaseline", "central", "set", "Pin text vertical alignment", ["auto", "use-script", "no-change", "reset-size", "ideographic", "alphabetic", "hanging", "mathematical", "central", "middle", "text-after-edge", "text-before-edge", "inherit"], { tags: ["Basic"] });