@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.
- package/LICENSE +43 -43
- package/README.md +88 -88
- package/TopoJSON/BR.json +122 -122
- package/TopoJSON/GB_idx.json +1 -1
- package/TopoJSON/IE_idx.json +1 -1
- package/TopoJSON/ND_idx.json +1 -1
- package/TopoJSON/countries.json +257 -257
- package/TopoJSON/us-counties.json +16550 -16550
- package/TopoJSON/us-states.json +458 -458
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +12 -10
- package/src/CanvasPinLayer.ts +99 -99
- package/src/CanvasPins.ts +397 -397
- package/src/Choropleth.css +26 -26
- package/src/Choropleth.ts +203 -203
- package/src/ChoroplethContinents.ts +13 -13
- package/src/ChoroplethCounties.ts +111 -111
- package/src/ChoroplethCountries.ts +100 -100
- package/src/ChoroplethStates.ts +103 -103
- package/src/ChoroplethStatesHeat.ts +8 -8
- package/src/GMap.css +20 -20
- package/src/GMap.ts +880 -880
- package/src/GMapCounties.ts +93 -93
- package/src/GMapGraph.ts +61 -61
- package/src/GMapHeat.ts +27 -27
- package/src/GMapLayered.ts +94 -94
- package/src/GMapPin.ts +115 -115
- package/src/GMapPinLine.ts +138 -138
- package/src/GeoHash.css +14 -14
- package/src/GeoHash.ts +139 -139
- package/src/Graph.css +9 -9
- package/src/Graph.ts +98 -98
- package/src/Graticule.css +12 -12
- package/src/Graticule.ts +97 -97
- package/src/Heat.ts +87 -87
- package/src/IChoropleth.ts +8 -8
- package/src/Layer.ts +99 -99
- package/src/Layered.css +18 -18
- package/src/Layered.ts +206 -206
- package/src/Lines.css +8 -8
- package/src/Lines.ts +78 -78
- package/src/OpenStreet.css +15 -15
- package/src/OpenStreet.ts +126 -126
- package/src/Pins.css +17 -17
- package/src/Pins.ts +350 -350
- package/src/Projection.ts +42 -42
- package/src/TestHeatMap.ts +8 -8
- package/src/TopoJSONChoropleth.ts +125 -125
- package/src/Utility.ts +484 -484
- package/src/__package__.ts +3 -3
- package/src/index.ts +33 -33
- package/src/leaflet/AlbersPR.ts +48 -48
- package/src/leaflet/Blank.ts +9 -9
- package/src/leaflet/Circles.ts +139 -139
- package/src/leaflet/ClusterCircles.css +26 -26
- package/src/leaflet/ClusterCircles.ts +88 -88
- package/src/leaflet/Countries.ts +43 -43
- package/src/leaflet/DrawLayer.ts +167 -167
- package/src/leaflet/FeatureLayer.ts +138 -138
- package/src/leaflet/GMap.ts +44 -44
- package/src/leaflet/HeatLayer.ts +77 -77
- package/src/leaflet/Icons.ts +60 -60
- package/src/leaflet/Leaflet.css +3 -3
- package/src/leaflet/Leaflet.ts +239 -239
- package/src/leaflet/MapBox.ts +35 -35
- package/src/leaflet/Markers.ts +109 -109
- package/src/leaflet/OpenStreet.ts +27 -27
- package/src/leaflet/Path.ts +138 -138
- package/src/leaflet/Pins.ts +73 -73
- package/src/leaflet/Polygons.ts +113 -113
- package/src/leaflet/Region.ts +138 -138
- package/src/leaflet/Text.ts +99 -99
- package/src/leaflet/TileLayer.ts +81 -81
- package/src/leaflet/TopoJSON.ts +146 -146
- package/src/leaflet/US.ts +15 -15
- package/src/leaflet/USCounties.ts +43 -43
- package/src/leaflet/USStates.ts +41 -41
- package/src/leaflet/World.css +3 -3
- package/src/leaflet/World.ts +172 -172
- package/src/leaflet/index.ts +18 -18
- package/src/leaflet/leaflet-shim.ts +18 -18
- package/src/leaflet/plugins/BeautifyIcon.css +44 -44
- package/src/leaflet/plugins/BeautifyIcon.ts +190 -190
- package/src/leaflet/plugins/BeutifyIcon.licence +20 -20
- package/src/leaflet/plugins/D3SvgOverlay.css +2 -2
- package/src/leaflet/plugins/D3SvgOverlay.licence +20 -20
- package/src/leaflet/plugins/D3SvgOverlay.ts +175 -175
- package/src/leaflet/plugins/HeatLayer.license +21 -21
- package/src/leaflet/plugins/HeatLayer.ts +224 -224
- package/src/leaflet/plugins/Leaflet.GoogleMutant.ts +424 -424
- package/src/leaflet/plugins/lru_map.ts +352 -352
- package/src/test.ts +114 -114
package/src/leaflet/US.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { LatLngBounds } from "./leaflet-shim.ts";
|
|
2
|
-
import { World } from "./World.ts";
|
|
3
|
-
|
|
4
|
-
export class US extends World {
|
|
5
|
-
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getBounds() {
|
|
11
|
-
const retVal = super.getBounds();
|
|
12
|
-
return new LatLngBounds([retVal.getNorth(), retVal.getWest()], [17.755278, -64.565]);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
import { LatLngBounds } from "./leaflet-shim.ts";
|
|
2
|
+
import { World } from "./World.ts";
|
|
3
|
+
|
|
4
|
+
export class US extends World {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getBounds() {
|
|
11
|
+
const retVal = super.getBounds();
|
|
12
|
+
return new LatLngBounds([retVal.getNorth(), retVal.getWest()], [17.755278, -64.565]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { json as d3Json } from "d3-request";
|
|
2
|
-
import * as topojson from "topojson-client";
|
|
3
|
-
import { topoJsonFolder } from "../Choropleth.ts";
|
|
4
|
-
import { US } from "./US.ts";
|
|
5
|
-
|
|
6
|
-
let usCounties = null;
|
|
7
|
-
const usCountyNames = {};
|
|
8
|
-
|
|
9
|
-
export class USCounties extends US {
|
|
10
|
-
|
|
11
|
-
init(): Promise<void> {
|
|
12
|
-
if (!this._initPromise) {
|
|
13
|
-
this._initPromise = new Promise((resolve, reject) => {
|
|
14
|
-
if (usCounties) {
|
|
15
|
-
resolve(usCounties);
|
|
16
|
-
}
|
|
17
|
-
d3Json(`${topoJsonFolder()}/us-counties.json`, function (_usCounties) {
|
|
18
|
-
usCounties = _usCounties;
|
|
19
|
-
resolve(usCounties);
|
|
20
|
-
});
|
|
21
|
-
}).then((usCounties: any) => {
|
|
22
|
-
this._features = topojson.feature(usCounties.topology, usCounties.topology.objects.counties).features;
|
|
23
|
-
for (const key in this._features) {
|
|
24
|
-
if (this._features[key].id) {
|
|
25
|
-
const code = this._features[key].id;
|
|
26
|
-
const name = usCounties.countyNames[code];
|
|
27
|
-
this._features[key].properties.hpccID = code;
|
|
28
|
-
usCountyNames[code] = name;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return this._initPromise;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
tooltipHandler(l, featureID) {
|
|
38
|
-
const row = this._dataMap[featureID];
|
|
39
|
-
const value = row && row[1] || "";
|
|
40
|
-
return this.tooltipText(this.rowToObj(row), `<b>${usCountyNames[featureID]}</b>: ${value}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
USCounties.prototype._class += " map_USCounties";
|
|
1
|
+
import { json as d3Json } from "d3-request";
|
|
2
|
+
import * as topojson from "topojson-client";
|
|
3
|
+
import { topoJsonFolder } from "../Choropleth.ts";
|
|
4
|
+
import { US } from "./US.ts";
|
|
5
|
+
|
|
6
|
+
let usCounties = null;
|
|
7
|
+
const usCountyNames = {};
|
|
8
|
+
|
|
9
|
+
export class USCounties extends US {
|
|
10
|
+
|
|
11
|
+
init(): Promise<void> {
|
|
12
|
+
if (!this._initPromise) {
|
|
13
|
+
this._initPromise = new Promise((resolve, reject) => {
|
|
14
|
+
if (usCounties) {
|
|
15
|
+
resolve(usCounties);
|
|
16
|
+
}
|
|
17
|
+
d3Json(`${topoJsonFolder()}/us-counties.json`, function (_usCounties) {
|
|
18
|
+
usCounties = _usCounties;
|
|
19
|
+
resolve(usCounties);
|
|
20
|
+
});
|
|
21
|
+
}).then((usCounties: any) => {
|
|
22
|
+
this._features = topojson.feature(usCounties.topology, usCounties.topology.objects.counties).features;
|
|
23
|
+
for (const key in this._features) {
|
|
24
|
+
if (this._features[key].id) {
|
|
25
|
+
const code = this._features[key].id;
|
|
26
|
+
const name = usCounties.countyNames[code];
|
|
27
|
+
this._features[key].properties.hpccID = code;
|
|
28
|
+
usCountyNames[code] = name;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return this._initPromise;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
tooltipHandler(l, featureID) {
|
|
38
|
+
const row = this._dataMap[featureID];
|
|
39
|
+
const value = row && row[1] || "";
|
|
40
|
+
return this.tooltipText(this.rowToObj(row), `<b>${usCountyNames[featureID]}</b>: ${value}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
USCounties.prototype._class += " map_USCounties";
|
package/src/leaflet/USStates.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { json as d3Json } from "d3-request";
|
|
2
|
-
import * as topojson from "topojson-client";
|
|
3
|
-
import { topoJsonFolder } from "../Choropleth.ts";
|
|
4
|
-
import { US } from "./US.ts";
|
|
5
|
-
|
|
6
|
-
let usStates = null;
|
|
7
|
-
const usStateNames = {};
|
|
8
|
-
|
|
9
|
-
export class USStates extends US {
|
|
10
|
-
|
|
11
|
-
init(): Promise<void> {
|
|
12
|
-
if (!this._initPromise) {
|
|
13
|
-
this._initPromise = new Promise((resolve, reject) => {
|
|
14
|
-
if (usStates) {
|
|
15
|
-
resolve(usStates);
|
|
16
|
-
}
|
|
17
|
-
d3Json(`${topoJsonFolder()}/us-states.json`, function (_usStates) {
|
|
18
|
-
usStates = _usStates;
|
|
19
|
-
resolve(usStates);
|
|
20
|
-
});
|
|
21
|
-
}).then((usStates: any) => {
|
|
22
|
-
this._features = topojson.feature(usStates.topology, usStates.topology.objects.states).features;
|
|
23
|
-
for (const key in this._features) {
|
|
24
|
-
if (this._features[key].id) {
|
|
25
|
-
const { code, name } = usStates.stateNames[this._features[key].id];
|
|
26
|
-
this._features[key].properties.hpccID = code;
|
|
27
|
-
usStateNames[code] = name;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return this._initPromise;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
tooltipHandler(l, featureID) {
|
|
36
|
-
const row = this._dataMap[featureID];
|
|
37
|
-
const value = row && row[1] || "";
|
|
38
|
-
return this.tooltipText(this.rowToObj(row), `<b>${usStateNames[featureID]}</b>: ${value}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
USStates.prototype._class += " map_USStates";
|
|
1
|
+
import { json as d3Json } from "d3-request";
|
|
2
|
+
import * as topojson from "topojson-client";
|
|
3
|
+
import { topoJsonFolder } from "../Choropleth.ts";
|
|
4
|
+
import { US } from "./US.ts";
|
|
5
|
+
|
|
6
|
+
let usStates = null;
|
|
7
|
+
const usStateNames = {};
|
|
8
|
+
|
|
9
|
+
export class USStates extends US {
|
|
10
|
+
|
|
11
|
+
init(): Promise<void> {
|
|
12
|
+
if (!this._initPromise) {
|
|
13
|
+
this._initPromise = new Promise((resolve, reject) => {
|
|
14
|
+
if (usStates) {
|
|
15
|
+
resolve(usStates);
|
|
16
|
+
}
|
|
17
|
+
d3Json(`${topoJsonFolder()}/us-states.json`, function (_usStates) {
|
|
18
|
+
usStates = _usStates;
|
|
19
|
+
resolve(usStates);
|
|
20
|
+
});
|
|
21
|
+
}).then((usStates: any) => {
|
|
22
|
+
this._features = topojson.feature(usStates.topology, usStates.topology.objects.states).features;
|
|
23
|
+
for (const key in this._features) {
|
|
24
|
+
if (this._features[key].id) {
|
|
25
|
+
const { code, name } = usStates.stateNames[this._features[key].id];
|
|
26
|
+
this._features[key].properties.hpccID = code;
|
|
27
|
+
usStateNames[code] = name;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return this._initPromise;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
tooltipHandler(l, featureID) {
|
|
36
|
+
const row = this._dataMap[featureID];
|
|
37
|
+
const value = row && row[1] || "";
|
|
38
|
+
return this.tooltipText(this.rowToObj(row), `<b>${usStateNames[featureID]}</b>: ${value}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
USStates.prototype._class += " map_USStates";
|
package/src/leaflet/World.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.leaflet-interactive.selected {
|
|
2
|
-
stroke: red;
|
|
3
|
-
stroke-width: 1.25px;
|
|
1
|
+
.leaflet-interactive.selected {
|
|
2
|
+
stroke: red;
|
|
3
|
+
stroke-width: 1.25px;
|
|
4
4
|
}
|
package/src/leaflet/World.ts
CHANGED
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
import { Palette, SVGGlowFilter, Utility } from "@hpcc-js/common";
|
|
2
|
-
import { LatLngBounds, Map } from "./leaflet-shim.ts";
|
|
3
|
-
import { select as d3Select } from "d3-selection";
|
|
4
|
-
import { FeatureLayer } from "./FeatureLayer.ts";
|
|
5
|
-
import { TopoJSON } from "./TopoJSON.ts";
|
|
6
|
-
|
|
7
|
-
import "../../src/leaflet/World.css";
|
|
8
|
-
|
|
9
|
-
export class World extends FeatureLayer {
|
|
10
|
-
|
|
11
|
-
protected _features;
|
|
12
|
-
_palette;
|
|
13
|
-
|
|
14
|
-
protected _dataMap = {};
|
|
15
|
-
protected _dataMinWeight = null;
|
|
16
|
-
protected _dataMaxWeight = null;
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
Utility.SimpleSelectionMixin.call(this);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
hasBounds() {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getBounds() {
|
|
28
|
-
const retVal = super.getBounds();
|
|
29
|
-
if (!retVal.isValid()) {
|
|
30
|
-
return new LatLngBounds([90, -180], [-90, 180]);
|
|
31
|
-
}
|
|
32
|
-
return new LatLngBounds([retVal.getNorth(), retVal.getWest()], [retVal.getSouth(), retVal.getEast()]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
updateDataMap(_?) {
|
|
36
|
-
this._dataMap = {};
|
|
37
|
-
this._dataMinWeight = null;
|
|
38
|
-
this._dataMaxWeight = null;
|
|
39
|
-
|
|
40
|
-
const context = this;
|
|
41
|
-
_.forEach(function (item) {
|
|
42
|
-
context._dataMap[item[0]] = item;
|
|
43
|
-
if (!context._dataMinWeight || item[1] < context._dataMinWeight) {
|
|
44
|
-
context._dataMinWeight = item[1];
|
|
45
|
-
}
|
|
46
|
-
if (!context._dataMaxWeight || item[1] > context._dataMaxWeight) {
|
|
47
|
-
context._dataMaxWeight = item[1];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
data(_?) {
|
|
53
|
-
const retVal = super.data.apply(this, arguments);
|
|
54
|
-
if (arguments.length) {
|
|
55
|
-
this.updateDataMap(_);
|
|
56
|
-
}
|
|
57
|
-
return retVal;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
styleFeature(feature) {
|
|
61
|
-
const d = this._dataMap[feature.properties.hpccID];
|
|
62
|
-
const fillColor = d ? this._palette(d[1], this._dataMinWeight, this._dataMaxWeight) : "transparent";
|
|
63
|
-
return {
|
|
64
|
-
color: this.meshVisible() ? this.meshColor() : undefined,
|
|
65
|
-
opacity: 1,
|
|
66
|
-
weight: this.meshStrokeWidth(),
|
|
67
|
-
fillColor,
|
|
68
|
-
fillOpacity: this.opacity()
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
svgGlowID() {
|
|
73
|
-
return this.id() + "_svgGlow";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private _topoJson;
|
|
77
|
-
private _svgElement;
|
|
78
|
-
layerEnter(map: Map) {
|
|
79
|
-
super.layerEnter(map);
|
|
80
|
-
if (!this._svgElement) {
|
|
81
|
-
this._svgElement = d3Select(map.getContainer()).select(".leaflet-pane.leaflet-overlay-pane > svg");
|
|
82
|
-
const svgDefs = this._svgElement.append("defs");
|
|
83
|
-
new SVGGlowFilter(svgDefs, this.svgGlowID());
|
|
84
|
-
this._selection.widgetElement(this._svgElement);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private _prevFeatures;
|
|
89
|
-
layerUpdate(map: Map) {
|
|
90
|
-
if (this._prevFeatures !== this._features) {
|
|
91
|
-
this.clear();
|
|
92
|
-
this._topoJson = new TopoJSON(this._features, {
|
|
93
|
-
onEachFeature: (f, l) => {
|
|
94
|
-
l.on("click", e => this.clickHandler(e, l, l.feature.properties.hpccID));
|
|
95
|
-
}
|
|
96
|
-
}).bindTooltip((l: any) => this.tooltipHandler(l, l.feature.properties.hpccID), {
|
|
97
|
-
direction: "top",
|
|
98
|
-
sticky: true
|
|
99
|
-
});
|
|
100
|
-
this.add(this._topoJson);
|
|
101
|
-
}
|
|
102
|
-
super.layerUpdate(map);
|
|
103
|
-
|
|
104
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
105
|
-
if (this.useClonedPalette()) {
|
|
106
|
-
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
this._topoJson.setStyle(feature => this.styleFeature(feature));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Events ---
|
|
113
|
-
clickHandler(e, l, featureID): boolean {
|
|
114
|
-
const sel = this._selection.click(e.originalEvent.target);
|
|
115
|
-
this.click(this.rowToObj(this._dataMap[featureID]), this.columns()[0], sel);
|
|
116
|
-
return sel;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
tooltipText(row: object, tooltip: string): string {
|
|
120
|
-
return tooltip;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
tooltipHandler(l, featureID) {
|
|
124
|
-
const row = this._dataMap[featureID];
|
|
125
|
-
const value = row && row[1] || "";
|
|
126
|
-
return this.tooltipText(this.rowToObj(row), `<b>${featureID}</b>: ${value}`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Events ---
|
|
130
|
-
click(row, col, sel) {
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
World.prototype._class += " map_World";
|
|
134
|
-
World.prototype._palette = Palette.rainbow("default");
|
|
135
|
-
World.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
136
|
-
|
|
137
|
-
export interface World {
|
|
138
|
-
paletteID(): string;
|
|
139
|
-
paletteID(_: string): this;
|
|
140
|
-
paletteID_exists(): boolean;
|
|
141
|
-
useClonedPalette(): boolean;
|
|
142
|
-
useClonedPalette(_: boolean): this;
|
|
143
|
-
useClonedPalette_exists(): boolean;
|
|
144
|
-
|
|
145
|
-
opacity(): number;
|
|
146
|
-
opacity(_: number): this;
|
|
147
|
-
opacity_default(_: number): this;
|
|
148
|
-
opacity_exists(): boolean;
|
|
149
|
-
|
|
150
|
-
meshVisible(): boolean;
|
|
151
|
-
meshVisible(_: boolean): this;
|
|
152
|
-
meshVisible_exists(): boolean;
|
|
153
|
-
meshColor(): string;
|
|
154
|
-
meshColor(_: string): this;
|
|
155
|
-
meshColor_exists(): boolean;
|
|
156
|
-
meshStrokeWidth(): number;
|
|
157
|
-
meshStrokeWidth(_: number): this;
|
|
158
|
-
meshStrokeWidth_exists(): boolean;
|
|
159
|
-
internalOnly(): boolean;
|
|
160
|
-
internalOnly(_: boolean): this;
|
|
161
|
-
internalOnly_exists(): boolean;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
World.prototype.publish("paletteID", "YlOrRd", "set", "Color palette for this widget", World.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
165
|
-
World.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
166
|
-
|
|
167
|
-
World.prototype.publish("opacity", 0.5, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
168
|
-
|
|
169
|
-
World.prototype.publish("meshVisible", true, "boolean", "Mesh Visibility");
|
|
170
|
-
World.prototype.publish("meshColor", "black", "html-color", "Stroke Color");
|
|
171
|
-
World.prototype.publish("meshStrokeWidth", 0.25, "number", "Stroke Width");
|
|
172
|
-
World.prototype.publish("internalOnly", false, "boolean", "Internal mesh only");
|
|
1
|
+
import { Palette, SVGGlowFilter, Utility } from "@hpcc-js/common";
|
|
2
|
+
import { LatLngBounds, Map } from "./leaflet-shim.ts";
|
|
3
|
+
import { select as d3Select } from "d3-selection";
|
|
4
|
+
import { FeatureLayer } from "./FeatureLayer.ts";
|
|
5
|
+
import { TopoJSON } from "./TopoJSON.ts";
|
|
6
|
+
|
|
7
|
+
import "../../src/leaflet/World.css";
|
|
8
|
+
|
|
9
|
+
export class World extends FeatureLayer {
|
|
10
|
+
|
|
11
|
+
protected _features;
|
|
12
|
+
_palette;
|
|
13
|
+
|
|
14
|
+
protected _dataMap = {};
|
|
15
|
+
protected _dataMinWeight = null;
|
|
16
|
+
protected _dataMaxWeight = null;
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
Utility.SimpleSelectionMixin.call(this);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
hasBounds() {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getBounds() {
|
|
28
|
+
const retVal = super.getBounds();
|
|
29
|
+
if (!retVal.isValid()) {
|
|
30
|
+
return new LatLngBounds([90, -180], [-90, 180]);
|
|
31
|
+
}
|
|
32
|
+
return new LatLngBounds([retVal.getNorth(), retVal.getWest()], [retVal.getSouth(), retVal.getEast()]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
updateDataMap(_?) {
|
|
36
|
+
this._dataMap = {};
|
|
37
|
+
this._dataMinWeight = null;
|
|
38
|
+
this._dataMaxWeight = null;
|
|
39
|
+
|
|
40
|
+
const context = this;
|
|
41
|
+
_.forEach(function (item) {
|
|
42
|
+
context._dataMap[item[0]] = item;
|
|
43
|
+
if (!context._dataMinWeight || item[1] < context._dataMinWeight) {
|
|
44
|
+
context._dataMinWeight = item[1];
|
|
45
|
+
}
|
|
46
|
+
if (!context._dataMaxWeight || item[1] > context._dataMaxWeight) {
|
|
47
|
+
context._dataMaxWeight = item[1];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
data(_?) {
|
|
53
|
+
const retVal = super.data.apply(this, arguments);
|
|
54
|
+
if (arguments.length) {
|
|
55
|
+
this.updateDataMap(_);
|
|
56
|
+
}
|
|
57
|
+
return retVal;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
styleFeature(feature) {
|
|
61
|
+
const d = this._dataMap[feature.properties.hpccID];
|
|
62
|
+
const fillColor = d ? this._palette(d[1], this._dataMinWeight, this._dataMaxWeight) : "transparent";
|
|
63
|
+
return {
|
|
64
|
+
color: this.meshVisible() ? this.meshColor() : undefined,
|
|
65
|
+
opacity: 1,
|
|
66
|
+
weight: this.meshStrokeWidth(),
|
|
67
|
+
fillColor,
|
|
68
|
+
fillOpacity: this.opacity()
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
svgGlowID() {
|
|
73
|
+
return this.id() + "_svgGlow";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private _topoJson;
|
|
77
|
+
private _svgElement;
|
|
78
|
+
layerEnter(map: Map) {
|
|
79
|
+
super.layerEnter(map);
|
|
80
|
+
if (!this._svgElement) {
|
|
81
|
+
this._svgElement = d3Select(map.getContainer()).select(".leaflet-pane.leaflet-overlay-pane > svg");
|
|
82
|
+
const svgDefs = this._svgElement.append("defs");
|
|
83
|
+
new SVGGlowFilter(svgDefs, this.svgGlowID());
|
|
84
|
+
this._selection.widgetElement(this._svgElement);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private _prevFeatures;
|
|
89
|
+
layerUpdate(map: Map) {
|
|
90
|
+
if (this._prevFeatures !== this._features) {
|
|
91
|
+
this.clear();
|
|
92
|
+
this._topoJson = new TopoJSON(this._features, {
|
|
93
|
+
onEachFeature: (f, l) => {
|
|
94
|
+
l.on("click", e => this.clickHandler(e, l, l.feature.properties.hpccID));
|
|
95
|
+
}
|
|
96
|
+
}).bindTooltip((l: any) => this.tooltipHandler(l, l.feature.properties.hpccID), {
|
|
97
|
+
direction: "top",
|
|
98
|
+
sticky: true
|
|
99
|
+
});
|
|
100
|
+
this.add(this._topoJson);
|
|
101
|
+
}
|
|
102
|
+
super.layerUpdate(map);
|
|
103
|
+
|
|
104
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
105
|
+
if (this.useClonedPalette()) {
|
|
106
|
+
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this._topoJson.setStyle(feature => this.styleFeature(feature));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Events ---
|
|
113
|
+
clickHandler(e, l, featureID): boolean {
|
|
114
|
+
const sel = this._selection.click(e.originalEvent.target);
|
|
115
|
+
this.click(this.rowToObj(this._dataMap[featureID]), this.columns()[0], sel);
|
|
116
|
+
return sel;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
tooltipText(row: object, tooltip: string): string {
|
|
120
|
+
return tooltip;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
tooltipHandler(l, featureID) {
|
|
124
|
+
const row = this._dataMap[featureID];
|
|
125
|
+
const value = row && row[1] || "";
|
|
126
|
+
return this.tooltipText(this.rowToObj(row), `<b>${featureID}</b>: ${value}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Events ---
|
|
130
|
+
click(row, col, sel) {
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
World.prototype._class += " map_World";
|
|
134
|
+
World.prototype._palette = Palette.rainbow("default");
|
|
135
|
+
World.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
136
|
+
|
|
137
|
+
export interface World {
|
|
138
|
+
paletteID(): string;
|
|
139
|
+
paletteID(_: string): this;
|
|
140
|
+
paletteID_exists(): boolean;
|
|
141
|
+
useClonedPalette(): boolean;
|
|
142
|
+
useClonedPalette(_: boolean): this;
|
|
143
|
+
useClonedPalette_exists(): boolean;
|
|
144
|
+
|
|
145
|
+
opacity(): number;
|
|
146
|
+
opacity(_: number): this;
|
|
147
|
+
opacity_default(_: number): this;
|
|
148
|
+
opacity_exists(): boolean;
|
|
149
|
+
|
|
150
|
+
meshVisible(): boolean;
|
|
151
|
+
meshVisible(_: boolean): this;
|
|
152
|
+
meshVisible_exists(): boolean;
|
|
153
|
+
meshColor(): string;
|
|
154
|
+
meshColor(_: string): this;
|
|
155
|
+
meshColor_exists(): boolean;
|
|
156
|
+
meshStrokeWidth(): number;
|
|
157
|
+
meshStrokeWidth(_: number): this;
|
|
158
|
+
meshStrokeWidth_exists(): boolean;
|
|
159
|
+
internalOnly(): boolean;
|
|
160
|
+
internalOnly(_: boolean): this;
|
|
161
|
+
internalOnly_exists(): boolean;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
World.prototype.publish("paletteID", "YlOrRd", "set", "Color palette for this widget", World.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
165
|
+
World.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
166
|
+
|
|
167
|
+
World.prototype.publish("opacity", 0.5, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
168
|
+
|
|
169
|
+
World.prototype.publish("meshVisible", true, "boolean", "Mesh Visibility");
|
|
170
|
+
World.prototype.publish("meshColor", "black", "html-color", "Stroke Color");
|
|
171
|
+
World.prototype.publish("meshStrokeWidth", 0.25, "number", "Stroke Width");
|
|
172
|
+
World.prototype.publish("internalOnly", false, "boolean", "Internal mesh only");
|
package/src/leaflet/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * from "./Circles.ts";
|
|
2
|
-
export * from "./ClusterCircles.ts";
|
|
3
|
-
export * from "./Countries.ts";
|
|
4
|
-
export * from "./DrawLayer.ts";
|
|
5
|
-
export * from "./FeatureLayer.ts";
|
|
6
|
-
export * from "./HeatLayer.ts";
|
|
7
|
-
export * from "./Icons.ts";
|
|
8
|
-
export * from "./Leaflet.ts";
|
|
9
|
-
export * from "./Markers.ts";
|
|
10
|
-
export * from "./Polygons.ts";
|
|
11
|
-
export * from "./Path.ts";
|
|
12
|
-
export * from "./Pins.ts";
|
|
13
|
-
export * from "./Region.ts";
|
|
14
|
-
export * from "./Text.ts";
|
|
15
|
-
export * from "./TileLayer.ts";
|
|
16
|
-
export * from "./USCounties.ts";
|
|
17
|
-
export * from "./USStates.ts";
|
|
18
|
-
export * from "./World.ts";
|
|
1
|
+
export * from "./Circles.ts";
|
|
2
|
+
export * from "./ClusterCircles.ts";
|
|
3
|
+
export * from "./Countries.ts";
|
|
4
|
+
export * from "./DrawLayer.ts";
|
|
5
|
+
export * from "./FeatureLayer.ts";
|
|
6
|
+
export * from "./HeatLayer.ts";
|
|
7
|
+
export * from "./Icons.ts";
|
|
8
|
+
export * from "./Leaflet.ts";
|
|
9
|
+
export * from "./Markers.ts";
|
|
10
|
+
export * from "./Polygons.ts";
|
|
11
|
+
export * from "./Path.ts";
|
|
12
|
+
export * from "./Pins.ts";
|
|
13
|
+
export * from "./Region.ts";
|
|
14
|
+
export * from "./Text.ts";
|
|
15
|
+
export * from "./TileLayer.ts";
|
|
16
|
+
export * from "./USCounties.ts";
|
|
17
|
+
export * from "./USStates.ts";
|
|
18
|
+
export * from "./World.ts";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import L, { Circle, Control, CRS, Direction, DivIcon, Draw, FeatureGroup, GeoJSON, Icon, LatLng, LatLngBounds, LatLngExpression, LeafletEvent, Map, Marker, point, Point, Polygon, Polyline, Rectangle, TileLayer, Transformation, Util } from "leaflet";
|
|
2
|
-
|
|
3
|
-
import "leaflet/dist/leaflet.css";
|
|
4
|
-
|
|
5
|
-
import "leaflet-draw";
|
|
6
|
-
import "leaflet-draw/dist/leaflet.draw.css";
|
|
7
|
-
import "leaflet.markercluster";
|
|
8
|
-
import "leaflet.markercluster/dist/MarkerCluster.css";
|
|
9
|
-
import "leaflet.markercluster/dist/MarkerCluster.Default.css";
|
|
10
|
-
|
|
11
|
-
export { GoogleMutant } from "./plugins/Leaflet.GoogleMutant.ts";
|
|
12
|
-
export { BeautifyIcon } from "./plugins/BeautifyIcon.ts";
|
|
13
|
-
export { D3SvgOverlay } from "./plugins/D3SvgOverlay.ts";
|
|
14
|
-
export { HeatLayer as LHeatLayer } from "./plugins/HeatLayer.ts";
|
|
15
|
-
|
|
16
|
-
export type MarkerClusterGroup = L.MarkerClusterGroup;
|
|
17
|
-
export const MarkerClusterGroup = L.MarkerClusterGroup;
|
|
18
|
-
|
|
1
|
+
import L, { Circle, Control, CRS, Direction, DivIcon, Draw, FeatureGroup, GeoJSON, Icon, LatLng, LatLngBounds, LatLngExpression, LeafletEvent, Map, Marker, point, Point, Polygon, Polyline, Rectangle, TileLayer, Transformation, Util } from "leaflet";
|
|
2
|
+
|
|
3
|
+
import "leaflet/dist/leaflet.css";
|
|
4
|
+
|
|
5
|
+
import "leaflet-draw";
|
|
6
|
+
import "leaflet-draw/dist/leaflet.draw.css";
|
|
7
|
+
import "leaflet.markercluster";
|
|
8
|
+
import "leaflet.markercluster/dist/MarkerCluster.css";
|
|
9
|
+
import "leaflet.markercluster/dist/MarkerCluster.Default.css";
|
|
10
|
+
|
|
11
|
+
export { GoogleMutant } from "./plugins/Leaflet.GoogleMutant.ts";
|
|
12
|
+
export { BeautifyIcon } from "./plugins/BeautifyIcon.ts";
|
|
13
|
+
export { D3SvgOverlay } from "./plugins/D3SvgOverlay.ts";
|
|
14
|
+
export { HeatLayer as LHeatLayer } from "./plugins/HeatLayer.ts";
|
|
15
|
+
|
|
16
|
+
export type MarkerClusterGroup = L.MarkerClusterGroup;
|
|
17
|
+
export const MarkerClusterGroup = L.MarkerClusterGroup;
|
|
18
|
+
|
|
19
19
|
export { L, Circle, Control, CRS, type Direction, DivIcon, Draw, FeatureGroup, GeoJSON, Icon, LatLng, LatLngBounds, type LatLngExpression, type LeafletEvent, Map, Marker, point, Point, Polygon, Polyline, Rectangle, TileLayer, Transformation, Util };
|