@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.
- 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 +7 -7
- package/src/CanvasPinLayer.ts +99 -99
- package/src/CanvasPins.ts +397 -397
- package/src/Choropleth.css +27 -27
- 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 +16 -16
- 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 +15 -15
- package/src/GeoHash.ts +139 -139
- package/src/Graph.css +10 -10
- package/src/Graph.ts +98 -98
- package/src/Graticule.css +13 -13
- package/src/Graticule.ts +97 -97
- package/src/Heat.css +2 -2
- package/src/Heat.ts +87 -87
- package/src/IChoropleth.ts +8 -8
- package/src/Layer.ts +99 -99
- package/src/Layered.css +19 -19
- package/src/Layered.ts +206 -206
- package/src/Lines.css +9 -9
- package/src/Lines.ts +78 -78
- package/src/OpenStreet.css +15 -15
- package/src/OpenStreet.ts +126 -126
- package/src/Pins.css +18 -18
- 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 +3 -3
- 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/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
-
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
-
export const BUILD_VERSION = "__BUILD_VERSION__";
|
|
1
|
+
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
+
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
+
export const BUILD_VERSION = "__BUILD_VERSION__";
|
package/src/index.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
export * from "./__package__.ts";
|
|
2
|
-
export * from "./CanvasPinLayer.ts";
|
|
3
|
-
export * from "./CanvasPins.ts";
|
|
4
|
-
export * from "./Choropleth.ts";
|
|
5
|
-
export * from "./ChoroplethContinents.ts";
|
|
6
|
-
export * from "./ChoroplethCounties.ts";
|
|
7
|
-
export * from "./ChoroplethCountries.ts";
|
|
8
|
-
export * from "./ChoroplethStates.ts";
|
|
9
|
-
export * from "./ChoroplethStatesHeat.ts";
|
|
10
|
-
export * from "./GeoHash.ts";
|
|
11
|
-
export * from "./GMap.ts";
|
|
12
|
-
export * from "./GMapCounties.ts";
|
|
13
|
-
export * from "./GMapGraph.ts";
|
|
14
|
-
export * from "./GMapHeat.ts";
|
|
15
|
-
export * from "./GMapLayered.ts";
|
|
16
|
-
export * from "./GMapPin.ts";
|
|
17
|
-
export * from "./GMapPinLine.ts";
|
|
18
|
-
export * from "./Graph.ts";
|
|
19
|
-
export * from "./Graticule.ts";
|
|
20
|
-
export * from "./Heat.ts";
|
|
21
|
-
export * from "./IChoropleth.ts";
|
|
22
|
-
export * from "./Layer.ts";
|
|
23
|
-
export * from "./Layered.ts";
|
|
24
|
-
export * from "./Lines.ts";
|
|
25
|
-
export * from "./OpenStreet.ts";
|
|
26
|
-
export * from "./Pins.ts";
|
|
27
|
-
export * from "./Projection.ts";
|
|
28
|
-
export * from "./TopoJSONChoropleth.ts";
|
|
29
|
-
|
|
30
|
-
import * as Leaflet from "./leaflet/index.ts";
|
|
31
|
-
export {
|
|
32
|
-
Leaflet
|
|
33
|
-
};
|
|
1
|
+
export * from "./__package__.ts";
|
|
2
|
+
export * from "./CanvasPinLayer.ts";
|
|
3
|
+
export * from "./CanvasPins.ts";
|
|
4
|
+
export * from "./Choropleth.ts";
|
|
5
|
+
export * from "./ChoroplethContinents.ts";
|
|
6
|
+
export * from "./ChoroplethCounties.ts";
|
|
7
|
+
export * from "./ChoroplethCountries.ts";
|
|
8
|
+
export * from "./ChoroplethStates.ts";
|
|
9
|
+
export * from "./ChoroplethStatesHeat.ts";
|
|
10
|
+
export * from "./GeoHash.ts";
|
|
11
|
+
export * from "./GMap.ts";
|
|
12
|
+
export * from "./GMapCounties.ts";
|
|
13
|
+
export * from "./GMapGraph.ts";
|
|
14
|
+
export * from "./GMapHeat.ts";
|
|
15
|
+
export * from "./GMapLayered.ts";
|
|
16
|
+
export * from "./GMapPin.ts";
|
|
17
|
+
export * from "./GMapPinLine.ts";
|
|
18
|
+
export * from "./Graph.ts";
|
|
19
|
+
export * from "./Graticule.ts";
|
|
20
|
+
export * from "./Heat.ts";
|
|
21
|
+
export * from "./IChoropleth.ts";
|
|
22
|
+
export * from "./Layer.ts";
|
|
23
|
+
export * from "./Layered.ts";
|
|
24
|
+
export * from "./Lines.ts";
|
|
25
|
+
export * from "./OpenStreet.ts";
|
|
26
|
+
export * from "./Pins.ts";
|
|
27
|
+
export * from "./Projection.ts";
|
|
28
|
+
export * from "./TopoJSONChoropleth.ts";
|
|
29
|
+
|
|
30
|
+
import * as Leaflet from "./leaflet/index.ts";
|
|
31
|
+
export {
|
|
32
|
+
Leaflet
|
|
33
|
+
};
|
package/src/leaflet/AlbersPR.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { CRS, LatLng, LatLngBounds, Point, Transformation, Util } from "./leaflet-shim.ts";
|
|
2
|
-
import { resolve } from "../Projection.ts";
|
|
3
|
-
import { TileLayer } from "./TileLayer.ts";
|
|
4
|
-
|
|
5
|
-
const projAlbers = resolve("Albers").scale(.5);
|
|
6
|
-
const projAlbersUsaPr = resolve("AlbersUsaPr").scale(.5);
|
|
7
|
-
|
|
8
|
-
const AlbersProjection = {
|
|
9
|
-
project(latLng) {
|
|
10
|
-
let point = projAlbersUsaPr([latLng.lng, latLng.lat]);
|
|
11
|
-
if (!point) {
|
|
12
|
-
point = projAlbers([latLng.lng, latLng.lat]);
|
|
13
|
-
}
|
|
14
|
-
return new Point(point[0], point[1]);
|
|
15
|
-
},
|
|
16
|
-
unproject(point) {
|
|
17
|
-
if (!isNaN(point.x) && !isNaN(point.y)) {
|
|
18
|
-
const latLng = projAlbers.invert([point.x, point.y]);
|
|
19
|
-
return new LatLng(latLng[1], latLng[0]);
|
|
20
|
-
} else {
|
|
21
|
-
return new LatLng(0, 0);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const AlbersCRS = Util.extend({}, CRS, {
|
|
27
|
-
projection: AlbersProjection,
|
|
28
|
-
transformation: new Transformation(1, 0, 1, 0),
|
|
29
|
-
infinite: true
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export class AlbersLayer extends TileLayer {
|
|
33
|
-
|
|
34
|
-
_crs = AlbersCRS;
|
|
35
|
-
|
|
36
|
-
constructor() {
|
|
37
|
-
super();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
hasBounds() {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getBounds() {
|
|
45
|
-
return new LatLngBounds([20, -123], [49, -64]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
AlbersLayer.prototype._class += " map_AlbersLayer";
|
|
1
|
+
import { CRS, LatLng, LatLngBounds, Point, Transformation, Util } from "./leaflet-shim.ts";
|
|
2
|
+
import { resolve } from "../Projection.ts";
|
|
3
|
+
import { TileLayer } from "./TileLayer.ts";
|
|
4
|
+
|
|
5
|
+
const projAlbers = resolve("Albers").scale(.5);
|
|
6
|
+
const projAlbersUsaPr = resolve("AlbersUsaPr").scale(.5);
|
|
7
|
+
|
|
8
|
+
const AlbersProjection = {
|
|
9
|
+
project(latLng) {
|
|
10
|
+
let point = projAlbersUsaPr([latLng.lng, latLng.lat]);
|
|
11
|
+
if (!point) {
|
|
12
|
+
point = projAlbers([latLng.lng, latLng.lat]);
|
|
13
|
+
}
|
|
14
|
+
return new Point(point[0], point[1]);
|
|
15
|
+
},
|
|
16
|
+
unproject(point) {
|
|
17
|
+
if (!isNaN(point.x) && !isNaN(point.y)) {
|
|
18
|
+
const latLng = projAlbers.invert([point.x, point.y]);
|
|
19
|
+
return new LatLng(latLng[1], latLng[0]);
|
|
20
|
+
} else {
|
|
21
|
+
return new LatLng(0, 0);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const AlbersCRS = Util.extend({}, CRS, {
|
|
27
|
+
projection: AlbersProjection,
|
|
28
|
+
transformation: new Transformation(1, 0, 1, 0),
|
|
29
|
+
infinite: true
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export class AlbersLayer extends TileLayer {
|
|
33
|
+
|
|
34
|
+
_crs = AlbersCRS;
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
hasBounds() {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getBounds() {
|
|
45
|
+
return new LatLngBounds([20, -123], [49, -64]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
AlbersLayer.prototype._class += " map_AlbersLayer";
|
package/src/leaflet/Blank.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TileLayer } from "./TileLayer.ts";
|
|
2
|
-
|
|
3
|
-
export class BlankLayer extends TileLayer {
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
BlankLayer.prototype._class += " map_BlankLayer";
|
|
1
|
+
import { TileLayer } from "./TileLayer.ts";
|
|
2
|
+
|
|
3
|
+
export class BlankLayer extends TileLayer {
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
BlankLayer.prototype._class += " map_BlankLayer";
|
package/src/leaflet/Circles.ts
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
import { Circle, Map } from "./leaflet-shim.ts";
|
|
2
|
-
import { ClusterLayer, D3SurfaceLayer } from "./FeatureLayer.ts";
|
|
3
|
-
|
|
4
|
-
export class Circles extends ClusterLayer {
|
|
5
|
-
|
|
6
|
-
hasBounds(): boolean {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
layerUpdate(map: Map) {
|
|
11
|
-
super.layerUpdate(map);
|
|
12
|
-
const columns = this.columns();
|
|
13
|
-
const latIdx = columns.indexOf(this.latitudeColumn());
|
|
14
|
-
const longIdx = columns.indexOf(this.longitudeColumn());
|
|
15
|
-
const strokeColorIdx = columns.indexOf(this.strokeColorColumn());
|
|
16
|
-
const fillColorIdx = columns.indexOf(this.fillColorColumn());
|
|
17
|
-
this.clear();
|
|
18
|
-
this.data().filter(row => !this.omitNullLatLong() || (!!row[latIdx] && !!row[longIdx])).forEach(row => {
|
|
19
|
-
this.add(new Circle([row[latIdx], row[longIdx]], {
|
|
20
|
-
color: this.propValue(strokeColorIdx, row, this.strokeColor()),
|
|
21
|
-
fill: true,
|
|
22
|
-
fillColor: this.propValue(fillColorIdx, row, this.fillColor()),
|
|
23
|
-
fillOpacity: this.fillOpacity(),
|
|
24
|
-
radius: this.radius(),
|
|
25
|
-
origRow: row
|
|
26
|
-
} as any).on("click", e => this.clickHandler(e, row)));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Events ---
|
|
31
|
-
clickHandler(e, row) {
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
Circles.prototype._class += " map_Circles";
|
|
35
|
-
|
|
36
|
-
export interface Circles {
|
|
37
|
-
latitudeColumn(): string;
|
|
38
|
-
latitudeColumn(_: string);
|
|
39
|
-
longitudeColumn(): string;
|
|
40
|
-
longitudeColumn(_: string);
|
|
41
|
-
radius(): number;
|
|
42
|
-
radius(_: number);
|
|
43
|
-
strokeColor(): string;
|
|
44
|
-
strokeColor(_: string);
|
|
45
|
-
strokeColorColumn(): string;
|
|
46
|
-
strokeColorColumn(_: string);
|
|
47
|
-
strokColorColumn_exists(): boolean;
|
|
48
|
-
fillColor(): string;
|
|
49
|
-
fillColor(_: string);
|
|
50
|
-
fillColorColumn(): string;
|
|
51
|
-
fillColorColumn(_: string);
|
|
52
|
-
fillColorColumn_exists(): boolean;
|
|
53
|
-
fillOpacity(): number;
|
|
54
|
-
fillOpacity(_: number);
|
|
55
|
-
omitNullLatLong(): boolean;
|
|
56
|
-
omitNullLatLong(_: boolean);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
Circles.prototype.publish("latitudeColumn", null, "set", "Latitude column", function () { return this.columns(); }, { optional: true });
|
|
60
|
-
Circles.prototype.publish("longitudeColumn", null, "set", "Longitude column", function () { return this.columns(); }, { optional: true });
|
|
61
|
-
Circles.prototype.publish("radius", 50, "number", "Radius (meters)");
|
|
62
|
-
Circles.prototype.publish("strokeColor", "#376cea", "html-color", "Stroke Color", null, { optional: true });
|
|
63
|
-
Circles.prototype.publish("strokeColorColumn", null, "set", "Stroke color column", function () { return this.columns(); }, { optional: true });
|
|
64
|
-
Circles.prototype.publish("fillColor", "#376cea", "html-color", "Fill Color", null, { optional: true });
|
|
65
|
-
Circles.prototype.publish("fillColorColumn", null, "set", "Fill color column", function () { return this.columns(); }, { optional: true });
|
|
66
|
-
Circles.prototype.publish("fillOpacity", 0.5, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
67
|
-
Circles.prototype.publish("omitNullLatLong", true, "boolean", "Remove lat=0,lng=0 from pinsData", null, { tags: ["Basic"] });
|
|
68
|
-
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
export class D3Circles extends D3SurfaceLayer {
|
|
71
|
-
|
|
72
|
-
layerUpdate(map: Map, projection?) {
|
|
73
|
-
super.layerUpdate(map, projection);
|
|
74
|
-
const element = this._lfd3._rootGroup;
|
|
75
|
-
projection = projection || this._lfd3.projection;
|
|
76
|
-
const columns = this.columns();
|
|
77
|
-
const latIdx = columns.indexOf(this.latitudeColumn());
|
|
78
|
-
const longIdx = columns.indexOf(this.longitudeColumn());
|
|
79
|
-
const strokeColorIdx = columns.indexOf(this.strokeColorColumn());
|
|
80
|
-
const fillColorIdx = columns.indexOf(this.fillColorColumn());
|
|
81
|
-
function toLatLng(d) {
|
|
82
|
-
return {
|
|
83
|
-
lat: +d[latIdx],
|
|
84
|
-
lng: +d[longIdx]
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
const updateSelection = element.selectAll("circle").data(this.data().filter(row => !this.omitNullLatLong() || (!!row[latIdx] && !!row[longIdx])));
|
|
88
|
-
updateSelection.enter()
|
|
89
|
-
.append("circle")
|
|
90
|
-
.merge(updateSelection)
|
|
91
|
-
.attr("cx", d => projection.latLngToLayerPoint(toLatLng(d)).x)
|
|
92
|
-
.attr("cy", d => projection.latLngToLayerPoint(toLatLng(d)).y)
|
|
93
|
-
.attr("r", Math.max(3 / projection.scale, this.radius() / projection.metresPerPixel)) // d => projection.metersToPixels(toLatLng(d), this.radius()))
|
|
94
|
-
.style("fill-opacity", this.fillOpacity())
|
|
95
|
-
.style("stroke", row => this.propValue(strokeColorIdx, row, this.strokeColor()))
|
|
96
|
-
.attr("stroke-width", Math.max(1 / projection.scale, 1 / projection.metresPerPixel))
|
|
97
|
-
.style("fill", row => this.propValue(fillColorIdx, row, this.fillColor()))
|
|
98
|
-
;
|
|
99
|
-
updateSelection.exit().remove();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Events ---
|
|
103
|
-
clickHandler(e, row) {
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
D3Circles.prototype._class += " map_D3Circles";
|
|
107
|
-
|
|
108
|
-
export interface D3Circles {
|
|
109
|
-
latitudeColumn(): string;
|
|
110
|
-
latitudeColumn(_: string);
|
|
111
|
-
longitudeColumn(): string;
|
|
112
|
-
longitudeColumn(_: string);
|
|
113
|
-
radius(): number;
|
|
114
|
-
radius(_: number);
|
|
115
|
-
strokeColor(): string;
|
|
116
|
-
strokeColor(_: string);
|
|
117
|
-
strokeColorColumn(): string;
|
|
118
|
-
strokeColorColumn(_: string);
|
|
119
|
-
strokColorColumn_exists(): boolean;
|
|
120
|
-
fillColor(): string;
|
|
121
|
-
fillColor(_: string);
|
|
122
|
-
fillColorColumn(): string;
|
|
123
|
-
fillColorColumn(_: string);
|
|
124
|
-
fillColorColumn_exists(): boolean;
|
|
125
|
-
fillOpacity(): number;
|
|
126
|
-
fillOpacity(_: number);
|
|
127
|
-
omitNullLatLong(): boolean;
|
|
128
|
-
omitNullLatLong(_: boolean);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
D3Circles.prototype.publish("latitudeColumn", null, "set", "Latitude column", function () { return this.columns(); }, { optional: true });
|
|
132
|
-
D3Circles.prototype.publish("longitudeColumn", null, "set", "Longitude column", function () { return this.columns(); }, { optional: true });
|
|
133
|
-
D3Circles.prototype.publish("radius", 50, "number", "Radius (meters)");
|
|
134
|
-
D3Circles.prototype.publish("strokeColor", "#376cea", "html-color", "Stroke Color", null, { optional: true });
|
|
135
|
-
D3Circles.prototype.publish("strokeColorColumn", null, "set", "Stroke color column", function () { return this.columns(); }, { optional: true });
|
|
136
|
-
D3Circles.prototype.publish("fillColor", "#376cea", "html-color", "Fill Color", null, { optional: true });
|
|
137
|
-
D3Circles.prototype.publish("fillColorColumn", null, "set", "Fill color column", function () { return this.columns(); }, { optional: true });
|
|
138
|
-
D3Circles.prototype.publish("fillOpacity", 0.5, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
139
|
-
D3Circles.prototype.publish("omitNullLatLong", true, "boolean", "Remove lat=0,lng=0 from pinsData", null, { tags: ["Basic"] });
|
|
1
|
+
import { Circle, Map } from "./leaflet-shim.ts";
|
|
2
|
+
import { ClusterLayer, D3SurfaceLayer } from "./FeatureLayer.ts";
|
|
3
|
+
|
|
4
|
+
export class Circles extends ClusterLayer {
|
|
5
|
+
|
|
6
|
+
hasBounds(): boolean {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
layerUpdate(map: Map) {
|
|
11
|
+
super.layerUpdate(map);
|
|
12
|
+
const columns = this.columns();
|
|
13
|
+
const latIdx = columns.indexOf(this.latitudeColumn());
|
|
14
|
+
const longIdx = columns.indexOf(this.longitudeColumn());
|
|
15
|
+
const strokeColorIdx = columns.indexOf(this.strokeColorColumn());
|
|
16
|
+
const fillColorIdx = columns.indexOf(this.fillColorColumn());
|
|
17
|
+
this.clear();
|
|
18
|
+
this.data().filter(row => !this.omitNullLatLong() || (!!row[latIdx] && !!row[longIdx])).forEach(row => {
|
|
19
|
+
this.add(new Circle([row[latIdx], row[longIdx]], {
|
|
20
|
+
color: this.propValue(strokeColorIdx, row, this.strokeColor()),
|
|
21
|
+
fill: true,
|
|
22
|
+
fillColor: this.propValue(fillColorIdx, row, this.fillColor()),
|
|
23
|
+
fillOpacity: this.fillOpacity(),
|
|
24
|
+
radius: this.radius(),
|
|
25
|
+
origRow: row
|
|
26
|
+
} as any).on("click", e => this.clickHandler(e, row)));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Events ---
|
|
31
|
+
clickHandler(e, row) {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
Circles.prototype._class += " map_Circles";
|
|
35
|
+
|
|
36
|
+
export interface Circles {
|
|
37
|
+
latitudeColumn(): string;
|
|
38
|
+
latitudeColumn(_: string);
|
|
39
|
+
longitudeColumn(): string;
|
|
40
|
+
longitudeColumn(_: string);
|
|
41
|
+
radius(): number;
|
|
42
|
+
radius(_: number);
|
|
43
|
+
strokeColor(): string;
|
|
44
|
+
strokeColor(_: string);
|
|
45
|
+
strokeColorColumn(): string;
|
|
46
|
+
strokeColorColumn(_: string);
|
|
47
|
+
strokColorColumn_exists(): boolean;
|
|
48
|
+
fillColor(): string;
|
|
49
|
+
fillColor(_: string);
|
|
50
|
+
fillColorColumn(): string;
|
|
51
|
+
fillColorColumn(_: string);
|
|
52
|
+
fillColorColumn_exists(): boolean;
|
|
53
|
+
fillOpacity(): number;
|
|
54
|
+
fillOpacity(_: number);
|
|
55
|
+
omitNullLatLong(): boolean;
|
|
56
|
+
omitNullLatLong(_: boolean);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Circles.prototype.publish("latitudeColumn", null, "set", "Latitude column", function () { return this.columns(); }, { optional: true });
|
|
60
|
+
Circles.prototype.publish("longitudeColumn", null, "set", "Longitude column", function () { return this.columns(); }, { optional: true });
|
|
61
|
+
Circles.prototype.publish("radius", 50, "number", "Radius (meters)");
|
|
62
|
+
Circles.prototype.publish("strokeColor", "#376cea", "html-color", "Stroke Color", null, { optional: true });
|
|
63
|
+
Circles.prototype.publish("strokeColorColumn", null, "set", "Stroke color column", function () { return this.columns(); }, { optional: true });
|
|
64
|
+
Circles.prototype.publish("fillColor", "#376cea", "html-color", "Fill Color", null, { optional: true });
|
|
65
|
+
Circles.prototype.publish("fillColorColumn", null, "set", "Fill color column", function () { return this.columns(); }, { optional: true });
|
|
66
|
+
Circles.prototype.publish("fillOpacity", 0.5, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
67
|
+
Circles.prototype.publish("omitNullLatLong", true, "boolean", "Remove lat=0,lng=0 from pinsData", null, { tags: ["Basic"] });
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
export class D3Circles extends D3SurfaceLayer {
|
|
71
|
+
|
|
72
|
+
layerUpdate(map: Map, projection?) {
|
|
73
|
+
super.layerUpdate(map, projection);
|
|
74
|
+
const element = this._lfd3._rootGroup;
|
|
75
|
+
projection = projection || this._lfd3.projection;
|
|
76
|
+
const columns = this.columns();
|
|
77
|
+
const latIdx = columns.indexOf(this.latitudeColumn());
|
|
78
|
+
const longIdx = columns.indexOf(this.longitudeColumn());
|
|
79
|
+
const strokeColorIdx = columns.indexOf(this.strokeColorColumn());
|
|
80
|
+
const fillColorIdx = columns.indexOf(this.fillColorColumn());
|
|
81
|
+
function toLatLng(d) {
|
|
82
|
+
return {
|
|
83
|
+
lat: +d[latIdx],
|
|
84
|
+
lng: +d[longIdx]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const updateSelection = element.selectAll("circle").data(this.data().filter(row => !this.omitNullLatLong() || (!!row[latIdx] && !!row[longIdx])));
|
|
88
|
+
updateSelection.enter()
|
|
89
|
+
.append("circle")
|
|
90
|
+
.merge(updateSelection)
|
|
91
|
+
.attr("cx", d => projection.latLngToLayerPoint(toLatLng(d)).x)
|
|
92
|
+
.attr("cy", d => projection.latLngToLayerPoint(toLatLng(d)).y)
|
|
93
|
+
.attr("r", Math.max(3 / projection.scale, this.radius() / projection.metresPerPixel)) // d => projection.metersToPixels(toLatLng(d), this.radius()))
|
|
94
|
+
.style("fill-opacity", this.fillOpacity())
|
|
95
|
+
.style("stroke", row => this.propValue(strokeColorIdx, row, this.strokeColor()))
|
|
96
|
+
.attr("stroke-width", Math.max(1 / projection.scale, 1 / projection.metresPerPixel))
|
|
97
|
+
.style("fill", row => this.propValue(fillColorIdx, row, this.fillColor()))
|
|
98
|
+
;
|
|
99
|
+
updateSelection.exit().remove();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Events ---
|
|
103
|
+
clickHandler(e, row) {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
D3Circles.prototype._class += " map_D3Circles";
|
|
107
|
+
|
|
108
|
+
export interface D3Circles {
|
|
109
|
+
latitudeColumn(): string;
|
|
110
|
+
latitudeColumn(_: string);
|
|
111
|
+
longitudeColumn(): string;
|
|
112
|
+
longitudeColumn(_: string);
|
|
113
|
+
radius(): number;
|
|
114
|
+
radius(_: number);
|
|
115
|
+
strokeColor(): string;
|
|
116
|
+
strokeColor(_: string);
|
|
117
|
+
strokeColorColumn(): string;
|
|
118
|
+
strokeColorColumn(_: string);
|
|
119
|
+
strokColorColumn_exists(): boolean;
|
|
120
|
+
fillColor(): string;
|
|
121
|
+
fillColor(_: string);
|
|
122
|
+
fillColorColumn(): string;
|
|
123
|
+
fillColorColumn(_: string);
|
|
124
|
+
fillColorColumn_exists(): boolean;
|
|
125
|
+
fillOpacity(): number;
|
|
126
|
+
fillOpacity(_: number);
|
|
127
|
+
omitNullLatLong(): boolean;
|
|
128
|
+
omitNullLatLong(_: boolean);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
D3Circles.prototype.publish("latitudeColumn", null, "set", "Latitude column", function () { return this.columns(); }, { optional: true });
|
|
132
|
+
D3Circles.prototype.publish("longitudeColumn", null, "set", "Longitude column", function () { return this.columns(); }, { optional: true });
|
|
133
|
+
D3Circles.prototype.publish("radius", 50, "number", "Radius (meters)");
|
|
134
|
+
D3Circles.prototype.publish("strokeColor", "#376cea", "html-color", "Stroke Color", null, { optional: true });
|
|
135
|
+
D3Circles.prototype.publish("strokeColorColumn", null, "set", "Stroke color column", function () { return this.columns(); }, { optional: true });
|
|
136
|
+
D3Circles.prototype.publish("fillColor", "#376cea", "html-color", "Fill Color", null, { optional: true });
|
|
137
|
+
D3Circles.prototype.publish("fillColorColumn", null, "set", "Fill color column", function () { return this.columns(); }, { optional: true });
|
|
138
|
+
D3Circles.prototype.publish("fillOpacity", 0.5, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
139
|
+
D3Circles.prototype.publish("omitNullLatLong", true, "boolean", "Remove lat=0,lng=0 from pinsData", null, { tags: ["Basic"] });
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
.cluster-circle {
|
|
2
|
-
background-clip: padding-box;
|
|
3
|
-
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.cluster-circle > div {
|
|
7
|
-
width: 40px;
|
|
8
|
-
height: 40px;
|
|
9
|
-
|
|
10
|
-
text-align: center;
|
|
11
|
-
border-radius: 20px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.cluster-circle > div > div {
|
|
15
|
-
display: inline-block;
|
|
16
|
-
margin-top: 5px;
|
|
17
|
-
width: 30px;
|
|
18
|
-
height: 30px;
|
|
19
|
-
|
|
20
|
-
text-align: center;
|
|
21
|
-
border-radius: 15px;
|
|
22
|
-
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.cluster-circle span {
|
|
26
|
-
line-height: 30px;
|
|
1
|
+
.cluster-circle {
|
|
2
|
+
background-clip: padding-box;
|
|
3
|
+
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.cluster-circle > div {
|
|
7
|
+
width: 40px;
|
|
8
|
+
height: 40px;
|
|
9
|
+
|
|
10
|
+
text-align: center;
|
|
11
|
+
border-radius: 20px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.cluster-circle > div > div {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
margin-top: 5px;
|
|
17
|
+
width: 30px;
|
|
18
|
+
height: 30px;
|
|
19
|
+
|
|
20
|
+
text-align: center;
|
|
21
|
+
border-radius: 15px;
|
|
22
|
+
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cluster-circle span {
|
|
26
|
+
line-height: 30px;
|
|
27
27
|
}
|