@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/Projection.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import * as d3Geo from "d3-geo";
|
|
2
|
-
import { albersUsaPr } from "./Utility.ts";
|
|
3
|
-
|
|
4
|
-
// const d3Geo = _d3Geo.geo || _d3Geo.default || _d3Geo;
|
|
5
|
-
|
|
6
|
-
enum Type {
|
|
7
|
-
AzimuthalEqualArea,
|
|
8
|
-
AzimuthalEquidistant,
|
|
9
|
-
Gnomonic,
|
|
10
|
-
Orthographic,
|
|
11
|
-
Stereographic,
|
|
12
|
-
AlbersUsa,
|
|
13
|
-
AlbersUsaPr,
|
|
14
|
-
Albers,
|
|
15
|
-
ConicConformal,
|
|
16
|
-
ConicEqualArea,
|
|
17
|
-
ConicEquidistant,
|
|
18
|
-
Equirectangular,
|
|
19
|
-
Mercator,
|
|
20
|
-
TransverseMercator
|
|
21
|
-
}
|
|
22
|
-
export const types: string[] = [];
|
|
23
|
-
export const projections: { [key: string]: any } = {};
|
|
24
|
-
for (const key in Type) {
|
|
25
|
-
if (typeof key === "string") {
|
|
26
|
-
types.push(key);
|
|
27
|
-
if (key === "AlbersUsaPr") {
|
|
28
|
-
projections[key] = albersUsaPr;
|
|
29
|
-
} else {
|
|
30
|
-
projections[key] = d3Geo[`geo${key}`];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function resolve(id: string): any {
|
|
36
|
-
const retVal = projections[id];
|
|
37
|
-
if (retVal) {
|
|
38
|
-
return retVal();
|
|
39
|
-
}
|
|
40
|
-
console.warn("Unknown projection: " + id);
|
|
41
|
-
return d3Geo.geoMercator();
|
|
42
|
-
}
|
|
1
|
+
import * as d3Geo from "d3-geo";
|
|
2
|
+
import { albersUsaPr } from "./Utility.ts";
|
|
3
|
+
|
|
4
|
+
// const d3Geo = _d3Geo.geo || _d3Geo.default || _d3Geo;
|
|
5
|
+
|
|
6
|
+
enum Type {
|
|
7
|
+
AzimuthalEqualArea,
|
|
8
|
+
AzimuthalEquidistant,
|
|
9
|
+
Gnomonic,
|
|
10
|
+
Orthographic,
|
|
11
|
+
Stereographic,
|
|
12
|
+
AlbersUsa,
|
|
13
|
+
AlbersUsaPr,
|
|
14
|
+
Albers,
|
|
15
|
+
ConicConformal,
|
|
16
|
+
ConicEqualArea,
|
|
17
|
+
ConicEquidistant,
|
|
18
|
+
Equirectangular,
|
|
19
|
+
Mercator,
|
|
20
|
+
TransverseMercator
|
|
21
|
+
}
|
|
22
|
+
export const types: string[] = [];
|
|
23
|
+
export const projections: { [key: string]: any } = {};
|
|
24
|
+
for (const key in Type) {
|
|
25
|
+
if (typeof key === "string") {
|
|
26
|
+
types.push(key);
|
|
27
|
+
if (key === "AlbersUsaPr") {
|
|
28
|
+
projections[key] = albersUsaPr;
|
|
29
|
+
} else {
|
|
30
|
+
projections[key] = d3Geo[`geo${key}`];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function resolve(id: string): any {
|
|
36
|
+
const retVal = projections[id];
|
|
37
|
+
if (retVal) {
|
|
38
|
+
return retVal();
|
|
39
|
+
}
|
|
40
|
+
console.warn("Unknown projection: " + id);
|
|
41
|
+
return d3Geo.geoMercator();
|
|
42
|
+
}
|
package/src/TestHeatMap.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Layered } from "./Layered.ts";
|
|
2
|
-
|
|
3
|
-
export class TestHeatMap extends Layered {
|
|
4
|
-
constructor() {
|
|
5
|
-
super();
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
TestHeatMap.prototype._class += " map_TestHeatMap";
|
|
1
|
+
import { Layered } from "./Layered.ts";
|
|
2
|
+
|
|
3
|
+
export class TestHeatMap extends Layered {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
TestHeatMap.prototype._class += " map_TestHeatMap";
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import { json as d3Json } from "d3-request";
|
|
2
|
-
import { select as d3Select } from "d3-selection";
|
|
3
|
-
import * as topojson from "topojson-client";
|
|
4
|
-
import { Choropleth, topoJsonFolder } from "./Choropleth.ts";
|
|
5
|
-
|
|
6
|
-
export class TopoJSONChoropleth extends Choropleth {
|
|
7
|
-
protected _prevRegion: string;
|
|
8
|
-
protected choroPaths: any;
|
|
9
|
-
protected _choroTopologyIndex: any;
|
|
10
|
-
protected _choroTopologyFeatures: any;
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
|
|
15
|
-
this.projection("Mercator");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
layerEnter(base, svgElement, domElement) {
|
|
19
|
-
Choropleth.prototype.layerEnter.apply(this, arguments);
|
|
20
|
-
|
|
21
|
-
this._selection.widgetElement(this._choroplethData);
|
|
22
|
-
this.choroPaths = d3Select(null);
|
|
23
|
-
|
|
24
|
-
const context = this;
|
|
25
|
-
this
|
|
26
|
-
.tooltipHTML(function (d) {
|
|
27
|
-
const columns = context.columns();
|
|
28
|
-
const series = columns && columns.length ? columns[0] : "Location";
|
|
29
|
-
const origData = d && d.length ? d[d.length - 1] : [""];
|
|
30
|
-
return context.tooltipFormat({ label: origData[0], series, value: d[1] });
|
|
31
|
-
})
|
|
32
|
-
;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
layerUpdate(base) {
|
|
36
|
-
Choropleth.prototype.layerUpdate.apply(this, arguments);
|
|
37
|
-
const data = [];
|
|
38
|
-
const context = this;
|
|
39
|
-
this.data().forEach(function (row) {
|
|
40
|
-
if (isNaN(row[0])) {
|
|
41
|
-
for (const key in context._choroTopologyIndex) {
|
|
42
|
-
for (const key2 in context._choroTopologyIndex[key]) {
|
|
43
|
-
if (key2 === row[0]) {
|
|
44
|
-
context._choroTopologyIndex[key][key2].forEach(function (idx) {
|
|
45
|
-
data.push([idx].concat(row.filter(function (d, i) { return i > 0; })).concat([row]));
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
data.push(row.concat([row]));
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
this.choroPaths = this._choroplethData.selectAll(".data").data(this.visible() ? data : [], function (d) { return d[0]; });
|
|
55
|
-
this.choroPaths.enter().append("path")
|
|
56
|
-
.attr("class", "data")
|
|
57
|
-
.call(this._selection.enter.bind(this._selection))
|
|
58
|
-
.on("click", function (d) {
|
|
59
|
-
if (context._dataMap[d[0]]) {
|
|
60
|
-
context.click(context.rowToObj(context._dataMap[d[0]]), "weight", context._selection.selected(context));
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.on("dblclick", function (d) {
|
|
64
|
-
if (context._dataMap[d[0]]) {
|
|
65
|
-
context.dblclick(context.rowToObj(context._dataMap[d[0]]), "weight", context._selection.selected(context));
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
.on("mouseout.tooltip", this.tooltip.hide)
|
|
69
|
-
.on("mousemove.tooltip", this.tooltip.show)
|
|
70
|
-
;
|
|
71
|
-
this.choroPaths
|
|
72
|
-
.attr("d", function (d) {
|
|
73
|
-
const retVal = base._d3GeoPath(context._choroTopologyFeatures[d[0]]);
|
|
74
|
-
if (!retVal) {
|
|
75
|
-
console.warn("Unknown Country: " + d);
|
|
76
|
-
}
|
|
77
|
-
return retVal;
|
|
78
|
-
})
|
|
79
|
-
.style("fill", function (d) {
|
|
80
|
-
const retVal = context._palette(d[1], context._dataMinWeight, context._dataMaxWeight);
|
|
81
|
-
return retVal;
|
|
82
|
-
})
|
|
83
|
-
;
|
|
84
|
-
this.choroPaths.exit().remove();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
layerPreRender() {
|
|
88
|
-
if (this._prevRegion !== this.region()) {
|
|
89
|
-
this._prevRegion = this.region();
|
|
90
|
-
delete this._topoJsonPromise;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!this._topoJsonPromise) {
|
|
94
|
-
const context = this;
|
|
95
|
-
this._topoJsonPromise = new Promise<void>(function (resolve, reject) {
|
|
96
|
-
d3Json(`${topoJsonFolder()}/${context.region()}.json`, function (region) {
|
|
97
|
-
context._choroTopology = region;
|
|
98
|
-
context._choroTopologyObjects = region.objects.PolbndA;
|
|
99
|
-
context._choroTopologyFeatures = topojson.feature(context._choroTopology, context._choroTopologyObjects).features;
|
|
100
|
-
|
|
101
|
-
d3Json(`${topoJsonFolder()}/${context.region()}_idx.json`, indexLoad)
|
|
102
|
-
.on("error", function (err) {
|
|
103
|
-
indexLoad({});
|
|
104
|
-
})
|
|
105
|
-
;
|
|
106
|
-
|
|
107
|
-
function indexLoad(index) {
|
|
108
|
-
context._choroTopologyIndex = index;
|
|
109
|
-
resolve();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return this._topoJsonPromise;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
TopoJSONChoropleth.prototype._class += " map_TopoJSONChoropleth";
|
|
118
|
-
|
|
119
|
-
export interface TopoJSONChoropleth {
|
|
120
|
-
region(): string;
|
|
121
|
-
region(_: string): this;
|
|
122
|
-
region_exists(): boolean;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
TopoJSONChoropleth.prototype.publish("region", "GB", "set", "Region Data", ["AT", "BE", "BG", "BR", "CHLI", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB", "GE", "GR", "HR", "HU", "IE", "IS", "IT", "KS", "LT", "LU", "LV", "MD", "MK", "MT", "ND", "NL", "NO", "PL", "PT", "RO", "RS", "SE", "SI", "SK", "UA"]);
|
|
1
|
+
import { json as d3Json } from "d3-request";
|
|
2
|
+
import { select as d3Select } from "d3-selection";
|
|
3
|
+
import * as topojson from "topojson-client";
|
|
4
|
+
import { Choropleth, topoJsonFolder } from "./Choropleth.ts";
|
|
5
|
+
|
|
6
|
+
export class TopoJSONChoropleth extends Choropleth {
|
|
7
|
+
protected _prevRegion: string;
|
|
8
|
+
protected choroPaths: any;
|
|
9
|
+
protected _choroTopologyIndex: any;
|
|
10
|
+
protected _choroTopologyFeatures: any;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
|
|
15
|
+
this.projection("Mercator");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
layerEnter(base, svgElement, domElement) {
|
|
19
|
+
Choropleth.prototype.layerEnter.apply(this, arguments);
|
|
20
|
+
|
|
21
|
+
this._selection.widgetElement(this._choroplethData);
|
|
22
|
+
this.choroPaths = d3Select(null);
|
|
23
|
+
|
|
24
|
+
const context = this;
|
|
25
|
+
this
|
|
26
|
+
.tooltipHTML(function (d) {
|
|
27
|
+
const columns = context.columns();
|
|
28
|
+
const series = columns && columns.length ? columns[0] : "Location";
|
|
29
|
+
const origData = d && d.length ? d[d.length - 1] : [""];
|
|
30
|
+
return context.tooltipFormat({ label: origData[0], series, value: d[1] });
|
|
31
|
+
})
|
|
32
|
+
;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
layerUpdate(base) {
|
|
36
|
+
Choropleth.prototype.layerUpdate.apply(this, arguments);
|
|
37
|
+
const data = [];
|
|
38
|
+
const context = this;
|
|
39
|
+
this.data().forEach(function (row) {
|
|
40
|
+
if (isNaN(row[0])) {
|
|
41
|
+
for (const key in context._choroTopologyIndex) {
|
|
42
|
+
for (const key2 in context._choroTopologyIndex[key]) {
|
|
43
|
+
if (key2 === row[0]) {
|
|
44
|
+
context._choroTopologyIndex[key][key2].forEach(function (idx) {
|
|
45
|
+
data.push([idx].concat(row.filter(function (d, i) { return i > 0; })).concat([row]));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
data.push(row.concat([row]));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
this.choroPaths = this._choroplethData.selectAll(".data").data(this.visible() ? data : [], function (d) { return d[0]; });
|
|
55
|
+
this.choroPaths.enter().append("path")
|
|
56
|
+
.attr("class", "data")
|
|
57
|
+
.call(this._selection.enter.bind(this._selection))
|
|
58
|
+
.on("click", function (d) {
|
|
59
|
+
if (context._dataMap[d[0]]) {
|
|
60
|
+
context.click(context.rowToObj(context._dataMap[d[0]]), "weight", context._selection.selected(context));
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
.on("dblclick", function (d) {
|
|
64
|
+
if (context._dataMap[d[0]]) {
|
|
65
|
+
context.dblclick(context.rowToObj(context._dataMap[d[0]]), "weight", context._selection.selected(context));
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
.on("mouseout.tooltip", this.tooltip.hide)
|
|
69
|
+
.on("mousemove.tooltip", this.tooltip.show)
|
|
70
|
+
;
|
|
71
|
+
this.choroPaths
|
|
72
|
+
.attr("d", function (d) {
|
|
73
|
+
const retVal = base._d3GeoPath(context._choroTopologyFeatures[d[0]]);
|
|
74
|
+
if (!retVal) {
|
|
75
|
+
console.warn("Unknown Country: " + d);
|
|
76
|
+
}
|
|
77
|
+
return retVal;
|
|
78
|
+
})
|
|
79
|
+
.style("fill", function (d) {
|
|
80
|
+
const retVal = context._palette(d[1], context._dataMinWeight, context._dataMaxWeight);
|
|
81
|
+
return retVal;
|
|
82
|
+
})
|
|
83
|
+
;
|
|
84
|
+
this.choroPaths.exit().remove();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
layerPreRender() {
|
|
88
|
+
if (this._prevRegion !== this.region()) {
|
|
89
|
+
this._prevRegion = this.region();
|
|
90
|
+
delete this._topoJsonPromise;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!this._topoJsonPromise) {
|
|
94
|
+
const context = this;
|
|
95
|
+
this._topoJsonPromise = new Promise<void>(function (resolve, reject) {
|
|
96
|
+
d3Json(`${topoJsonFolder()}/${context.region()}.json`, function (region) {
|
|
97
|
+
context._choroTopology = region;
|
|
98
|
+
context._choroTopologyObjects = region.objects.PolbndA;
|
|
99
|
+
context._choroTopologyFeatures = topojson.feature(context._choroTopology, context._choroTopologyObjects).features;
|
|
100
|
+
|
|
101
|
+
d3Json(`${topoJsonFolder()}/${context.region()}_idx.json`, indexLoad)
|
|
102
|
+
.on("error", function (err) {
|
|
103
|
+
indexLoad({});
|
|
104
|
+
})
|
|
105
|
+
;
|
|
106
|
+
|
|
107
|
+
function indexLoad(index) {
|
|
108
|
+
context._choroTopologyIndex = index;
|
|
109
|
+
resolve();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return this._topoJsonPromise;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
TopoJSONChoropleth.prototype._class += " map_TopoJSONChoropleth";
|
|
118
|
+
|
|
119
|
+
export interface TopoJSONChoropleth {
|
|
120
|
+
region(): string;
|
|
121
|
+
region(_: string): this;
|
|
122
|
+
region_exists(): boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
TopoJSONChoropleth.prototype.publish("region", "GB", "set", "Region Data", ["AT", "BE", "BG", "BR", "CHLI", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB", "GE", "GR", "HR", "HU", "IE", "IS", "IT", "KS", "LT", "LU", "LV", "MD", "MK", "MT", "ND", "NL", "NO", "PL", "PT", "RO", "RS", "SE", "SI", "SK", "UA"]);
|