@hpcc-js/map 3.5.2 → 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.
- 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 +9 -9
- 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/types/Layered.d.ts +1 -1
package/src/Layered.ts
CHANGED
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
import { SVGZoomWidget } from "@hpcc-js/common";
|
|
2
|
-
import { geoPath as d3GeoPath } from "d3-geo";
|
|
3
|
-
import { select as d3Select } from "d3-selection";
|
|
4
|
-
import { resolve, types as projectionTypes } from "./Projection.ts";
|
|
5
|
-
import "./Utility"; // For albersUsaPr
|
|
6
|
-
|
|
7
|
-
import "../src/Layered.css";
|
|
8
|
-
|
|
9
|
-
// const zoomFactor = 1 / 4;
|
|
10
|
-
const projectionFactor = (1 << 12) / 2 / Math.PI;
|
|
11
|
-
|
|
12
|
-
export class Layered extends SVGZoomWidget {
|
|
13
|
-
_autoScaleOnNextRender;
|
|
14
|
-
_layersTarget;
|
|
15
|
-
_prevAutoScaleMode;
|
|
16
|
-
_d3GeoProjection;
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
|
|
21
|
-
this._drawStartPos = "origin";
|
|
22
|
-
this.projection("Mercator");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
data(_?) {
|
|
26
|
-
const retVal = super.data.apply(this, arguments);
|
|
27
|
-
if (arguments.length) {
|
|
28
|
-
this._autoScaleOnNextRender = true;
|
|
29
|
-
}
|
|
30
|
-
return retVal;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
enter(domNode, element) {
|
|
34
|
-
super.enter(domNode, element);
|
|
35
|
-
this._layersTarget = this._renderElement.append("g")
|
|
36
|
-
.attr("class", "layersTarget")
|
|
37
|
-
;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
update(domNode, element) {
|
|
41
|
-
super.update(domNode, element);
|
|
42
|
-
|
|
43
|
-
const layers = this._layersTarget.selectAll(".layerContainer").data(this.layers().filter(function (d) { return d.visible(); }), function (d) { return d.id(); });
|
|
44
|
-
const context = this;
|
|
45
|
-
layers.enter().append("g")
|
|
46
|
-
.attr("id", function (d) { return d.id(); })
|
|
47
|
-
.attr("class", "layerContainer")
|
|
48
|
-
.each(function (d) {
|
|
49
|
-
d._svgElement = d3Select(this);
|
|
50
|
-
d._domElement = context._parentOverlay.append("div");
|
|
51
|
-
d.layerEnter(context, d._svgElement, d._domElement);
|
|
52
|
-
}).merge(layers)
|
|
53
|
-
.each(function (d) {
|
|
54
|
-
d.layerUpdate(context);
|
|
55
|
-
})
|
|
56
|
-
;
|
|
57
|
-
layers.exit()
|
|
58
|
-
.each(function (d) {
|
|
59
|
-
d.layerExit(context);
|
|
60
|
-
d._domElement.remove();
|
|
61
|
-
})
|
|
62
|
-
.remove()
|
|
63
|
-
;
|
|
64
|
-
layers.order();
|
|
65
|
-
this.onZoomed();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
exit(domNode, element) {
|
|
69
|
-
super.exit(domNode, element);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
onZoomed() {
|
|
73
|
-
super.onZoomed();
|
|
74
|
-
const layers = this._layersTarget.selectAll(".layerContainer");
|
|
75
|
-
const context = this;
|
|
76
|
-
layers
|
|
77
|
-
.each(function (d) {
|
|
78
|
-
d.layerZoomed(context);
|
|
79
|
-
})
|
|
80
|
-
;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
preRender(callback?) {
|
|
84
|
-
return Promise.all(this.layers().filter(function (layer) {
|
|
85
|
-
return layer.visible();
|
|
86
|
-
}).map(function (layer) {
|
|
87
|
-
return layer.layerPreRender();
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
render(callback?) {
|
|
92
|
-
const context = this;
|
|
93
|
-
this.preRender().then(function () {
|
|
94
|
-
SVGZoomWidget.prototype.render.call(context, function (w) {
|
|
95
|
-
if (context._layersTarget && ((context._renderCount && context._autoScaleOnNextRender) || context._prevAutoScaleMode !== context.autoScaleMode())) {
|
|
96
|
-
context._prevAutoScaleMode = context.autoScaleMode();
|
|
97
|
-
context._autoScaleOnNextRender = false;
|
|
98
|
-
context.autoScale();
|
|
99
|
-
if (callback) {
|
|
100
|
-
callback(w);
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
if (callback) {
|
|
104
|
-
callback(w);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
project(lat, long) {
|
|
113
|
-
if (lat >= 90)
|
|
114
|
-
lat = 89;
|
|
115
|
-
else if (lat <= -90)
|
|
116
|
-
lat = -89;
|
|
117
|
-
const pos = this._d3GeoProjection([long, lat]);
|
|
118
|
-
if (pos) {
|
|
119
|
-
// pos[0] *= this._zoom.scale();
|
|
120
|
-
// pos[1] *= this._zoom.scale();
|
|
121
|
-
// pos[0] += this._zoom.translate()[0];
|
|
122
|
-
// os[1] += this._zoom.translate()[1];
|
|
123
|
-
}
|
|
124
|
-
return pos;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
invert(x, y) {
|
|
128
|
-
// x -= this._zoom.translate()[0];
|
|
129
|
-
// y -= this._zoom.translate()[1];
|
|
130
|
-
// x /= this._zoom.scale();
|
|
131
|
-
// y /= this._zoom.scale();
|
|
132
|
-
return this._d3GeoProjection.invert([x, y]);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
getBounds() {
|
|
136
|
-
const bbox = this._layersTarget.node().getBBox();
|
|
137
|
-
return {
|
|
138
|
-
x: bbox.x,
|
|
139
|
-
y: bbox.y,
|
|
140
|
-
width: bbox.width,
|
|
141
|
-
height: bbox.height
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
autoScale() {
|
|
146
|
-
switch (this.autoScaleMode()) {
|
|
147
|
-
case "none":
|
|
148
|
-
return;
|
|
149
|
-
case "all":
|
|
150
|
-
this.zoomToBBox(this.getBounds());
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
Layered.prototype._class += " map_Layered";
|
|
156
|
-
|
|
157
|
-
export interface Layered {
|
|
158
|
-
projection(): string;
|
|
159
|
-
projection(_: string): this;
|
|
160
|
-
projection_exists(): boolean;
|
|
161
|
-
centerLat(): number;
|
|
162
|
-
centerLat(_: number): this;
|
|
163
|
-
centerLat_exists(): boolean;
|
|
164
|
-
centerLong(): number;
|
|
165
|
-
centerLong(_: number): this;
|
|
166
|
-
centerLong_exists(): boolean;
|
|
167
|
-
zoom(): number;
|
|
168
|
-
zoom(_: number): this;
|
|
169
|
-
zoom_exists(): boolean;
|
|
170
|
-
autoScaleMode(): string;
|
|
171
|
-
autoScaleMode(_: string): this;
|
|
172
|
-
autoScaleMode_exists(): boolean;
|
|
173
|
-
layers(): any[];
|
|
174
|
-
layers(_: any[]): this;
|
|
175
|
-
layers_exists(): boolean;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
Layered.prototype.publish("projection", null, "set", "Map projection type", projectionTypes);
|
|
179
|
-
Layered.prototype.publish("centerLat", 0, "number", "Center Latitude", null, { tags: ["Basic"] });
|
|
180
|
-
Layered.prototype.publish("centerLong", 0, "number", "Center Longitude", null, { tags: ["Basic"] });
|
|
181
|
-
Layered.prototype.publish("zoom", 1, "number", "Zoom Level", null, { tags: ["Basic"] });
|
|
182
|
-
Layered.prototype.publish("autoScaleMode", "all", "set", "Auto Scale", ["none", "all"], { tags: ["Basic"] });
|
|
183
|
-
Layered.prototype.publish("layers", [], "widgetArray", "Layers", null, { render: false });
|
|
184
|
-
|
|
185
|
-
const projection_orig = Layered.prototype.projection;
|
|
186
|
-
Layered.prototype.projection = function (_?) {
|
|
187
|
-
const retVal = projection_orig.apply(this, arguments);
|
|
188
|
-
if (arguments.length) {
|
|
189
|
-
this._d3GeoProjection = resolve(_)
|
|
190
|
-
.scale(projectionFactor)
|
|
191
|
-
.translate([0, 0])
|
|
192
|
-
;
|
|
193
|
-
switch (_) {
|
|
194
|
-
case "orthographic":
|
|
195
|
-
this._d3GeoProjection
|
|
196
|
-
.clipAngle(90)
|
|
197
|
-
.rotate([0, 0])
|
|
198
|
-
;
|
|
199
|
-
}
|
|
200
|
-
this._d3GeoPath = d3GeoPath()
|
|
201
|
-
.projection(this._d3GeoProjection)
|
|
202
|
-
;
|
|
203
|
-
this._autoScaleOnNextRender = true;
|
|
204
|
-
}
|
|
205
|
-
return retVal;
|
|
206
|
-
};
|
|
1
|
+
import { SVGZoomWidget } from "@hpcc-js/common";
|
|
2
|
+
import { geoPath as d3GeoPath } from "d3-geo";
|
|
3
|
+
import { select as d3Select } from "d3-selection";
|
|
4
|
+
import { resolve, types as projectionTypes } from "./Projection.ts";
|
|
5
|
+
import "./Utility.ts"; // For albersUsaPr
|
|
6
|
+
|
|
7
|
+
import "../src/Layered.css";
|
|
8
|
+
|
|
9
|
+
// const zoomFactor = 1 / 4;
|
|
10
|
+
const projectionFactor = (1 << 12) / 2 / Math.PI;
|
|
11
|
+
|
|
12
|
+
export class Layered extends SVGZoomWidget {
|
|
13
|
+
_autoScaleOnNextRender;
|
|
14
|
+
_layersTarget;
|
|
15
|
+
_prevAutoScaleMode;
|
|
16
|
+
_d3GeoProjection;
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
|
|
21
|
+
this._drawStartPos = "origin";
|
|
22
|
+
this.projection("Mercator");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
data(_?) {
|
|
26
|
+
const retVal = super.data.apply(this, arguments);
|
|
27
|
+
if (arguments.length) {
|
|
28
|
+
this._autoScaleOnNextRender = true;
|
|
29
|
+
}
|
|
30
|
+
return retVal;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
enter(domNode, element) {
|
|
34
|
+
super.enter(domNode, element);
|
|
35
|
+
this._layersTarget = this._renderElement.append("g")
|
|
36
|
+
.attr("class", "layersTarget")
|
|
37
|
+
;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
update(domNode, element) {
|
|
41
|
+
super.update(domNode, element);
|
|
42
|
+
|
|
43
|
+
const layers = this._layersTarget.selectAll(".layerContainer").data(this.layers().filter(function (d) { return d.visible(); }), function (d) { return d.id(); });
|
|
44
|
+
const context = this;
|
|
45
|
+
layers.enter().append("g")
|
|
46
|
+
.attr("id", function (d) { return d.id(); })
|
|
47
|
+
.attr("class", "layerContainer")
|
|
48
|
+
.each(function (d) {
|
|
49
|
+
d._svgElement = d3Select(this);
|
|
50
|
+
d._domElement = context._parentOverlay.append("div");
|
|
51
|
+
d.layerEnter(context, d._svgElement, d._domElement);
|
|
52
|
+
}).merge(layers)
|
|
53
|
+
.each(function (d) {
|
|
54
|
+
d.layerUpdate(context);
|
|
55
|
+
})
|
|
56
|
+
;
|
|
57
|
+
layers.exit()
|
|
58
|
+
.each(function (d) {
|
|
59
|
+
d.layerExit(context);
|
|
60
|
+
d._domElement.remove();
|
|
61
|
+
})
|
|
62
|
+
.remove()
|
|
63
|
+
;
|
|
64
|
+
layers.order();
|
|
65
|
+
this.onZoomed();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exit(domNode, element) {
|
|
69
|
+
super.exit(domNode, element);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
onZoomed() {
|
|
73
|
+
super.onZoomed();
|
|
74
|
+
const layers = this._layersTarget.selectAll(".layerContainer");
|
|
75
|
+
const context = this;
|
|
76
|
+
layers
|
|
77
|
+
.each(function (d) {
|
|
78
|
+
d.layerZoomed(context);
|
|
79
|
+
})
|
|
80
|
+
;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
preRender(callback?) {
|
|
84
|
+
return Promise.all(this.layers().filter(function (layer) {
|
|
85
|
+
return layer.visible();
|
|
86
|
+
}).map(function (layer) {
|
|
87
|
+
return layer.layerPreRender();
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render(callback?) {
|
|
92
|
+
const context = this;
|
|
93
|
+
this.preRender().then(function () {
|
|
94
|
+
SVGZoomWidget.prototype.render.call(context, function (w) {
|
|
95
|
+
if (context._layersTarget && ((context._renderCount && context._autoScaleOnNextRender) || context._prevAutoScaleMode !== context.autoScaleMode())) {
|
|
96
|
+
context._prevAutoScaleMode = context.autoScaleMode();
|
|
97
|
+
context._autoScaleOnNextRender = false;
|
|
98
|
+
context.autoScale();
|
|
99
|
+
if (callback) {
|
|
100
|
+
callback(w);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
if (callback) {
|
|
104
|
+
callback(w);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
project(lat, long) {
|
|
113
|
+
if (lat >= 90)
|
|
114
|
+
lat = 89;
|
|
115
|
+
else if (lat <= -90)
|
|
116
|
+
lat = -89;
|
|
117
|
+
const pos = this._d3GeoProjection([long, lat]);
|
|
118
|
+
if (pos) {
|
|
119
|
+
// pos[0] *= this._zoom.scale();
|
|
120
|
+
// pos[1] *= this._zoom.scale();
|
|
121
|
+
// pos[0] += this._zoom.translate()[0];
|
|
122
|
+
// os[1] += this._zoom.translate()[1];
|
|
123
|
+
}
|
|
124
|
+
return pos;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
invert(x, y) {
|
|
128
|
+
// x -= this._zoom.translate()[0];
|
|
129
|
+
// y -= this._zoom.translate()[1];
|
|
130
|
+
// x /= this._zoom.scale();
|
|
131
|
+
// y /= this._zoom.scale();
|
|
132
|
+
return this._d3GeoProjection.invert([x, y]);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getBounds() {
|
|
136
|
+
const bbox = this._layersTarget.node().getBBox();
|
|
137
|
+
return {
|
|
138
|
+
x: bbox.x,
|
|
139
|
+
y: bbox.y,
|
|
140
|
+
width: bbox.width,
|
|
141
|
+
height: bbox.height
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
autoScale() {
|
|
146
|
+
switch (this.autoScaleMode()) {
|
|
147
|
+
case "none":
|
|
148
|
+
return;
|
|
149
|
+
case "all":
|
|
150
|
+
this.zoomToBBox(this.getBounds());
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
Layered.prototype._class += " map_Layered";
|
|
156
|
+
|
|
157
|
+
export interface Layered {
|
|
158
|
+
projection(): string;
|
|
159
|
+
projection(_: string): this;
|
|
160
|
+
projection_exists(): boolean;
|
|
161
|
+
centerLat(): number;
|
|
162
|
+
centerLat(_: number): this;
|
|
163
|
+
centerLat_exists(): boolean;
|
|
164
|
+
centerLong(): number;
|
|
165
|
+
centerLong(_: number): this;
|
|
166
|
+
centerLong_exists(): boolean;
|
|
167
|
+
zoom(): number;
|
|
168
|
+
zoom(_: number): this;
|
|
169
|
+
zoom_exists(): boolean;
|
|
170
|
+
autoScaleMode(): string;
|
|
171
|
+
autoScaleMode(_: string): this;
|
|
172
|
+
autoScaleMode_exists(): boolean;
|
|
173
|
+
layers(): any[];
|
|
174
|
+
layers(_: any[]): this;
|
|
175
|
+
layers_exists(): boolean;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
Layered.prototype.publish("projection", null, "set", "Map projection type", projectionTypes);
|
|
179
|
+
Layered.prototype.publish("centerLat", 0, "number", "Center Latitude", null, { tags: ["Basic"] });
|
|
180
|
+
Layered.prototype.publish("centerLong", 0, "number", "Center Longitude", null, { tags: ["Basic"] });
|
|
181
|
+
Layered.prototype.publish("zoom", 1, "number", "Zoom Level", null, { tags: ["Basic"] });
|
|
182
|
+
Layered.prototype.publish("autoScaleMode", "all", "set", "Auto Scale", ["none", "all"], { tags: ["Basic"] });
|
|
183
|
+
Layered.prototype.publish("layers", [], "widgetArray", "Layers", null, { render: false });
|
|
184
|
+
|
|
185
|
+
const projection_orig = Layered.prototype.projection;
|
|
186
|
+
Layered.prototype.projection = function (_?) {
|
|
187
|
+
const retVal = projection_orig.apply(this, arguments);
|
|
188
|
+
if (arguments.length) {
|
|
189
|
+
this._d3GeoProjection = resolve(_)
|
|
190
|
+
.scale(projectionFactor)
|
|
191
|
+
.translate([0, 0])
|
|
192
|
+
;
|
|
193
|
+
switch (_) {
|
|
194
|
+
case "orthographic":
|
|
195
|
+
this._d3GeoProjection
|
|
196
|
+
.clipAngle(90)
|
|
197
|
+
.rotate([0, 0])
|
|
198
|
+
;
|
|
199
|
+
}
|
|
200
|
+
this._d3GeoPath = d3GeoPath()
|
|
201
|
+
.projection(this._d3GeoProjection)
|
|
202
|
+
;
|
|
203
|
+
this._autoScaleOnNextRender = true;
|
|
204
|
+
}
|
|
205
|
+
return retVal;
|
|
206
|
+
};
|
package/src/Lines.css
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
.map_Layered .marker {
|
|
2
|
-
fill: #656565;
|
|
3
|
-
stroke: none;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.map_Layered .dataEdge {
|
|
7
|
-
stroke: black;
|
|
8
|
-
fill: none;
|
|
1
|
+
.map_Layered .marker {
|
|
2
|
+
fill: #656565;
|
|
3
|
+
stroke: none;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.map_Layered .dataEdge {
|
|
7
|
+
stroke: black;
|
|
8
|
+
fill: none;
|
|
9
9
|
}
|
package/src/Lines.ts
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { Layer } from "./Layer.ts";
|
|
2
|
-
|
|
3
|
-
import "../src/Lines.css";
|
|
4
|
-
|
|
5
|
-
export class Lines extends Layer {
|
|
6
|
-
dataEdges;
|
|
7
|
-
_edgesTransform;
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
data(_) {
|
|
14
|
-
const retVal = Layer.prototype.data.apply(this, arguments);
|
|
15
|
-
if (arguments.length) {
|
|
16
|
-
this.dataEdges = [];
|
|
17
|
-
_.forEach(function (row) {
|
|
18
|
-
this.dataEdges.push({
|
|
19
|
-
type: "LineString",
|
|
20
|
-
coordinates: [[row[1], row[0]], [row[3], row[2]]]
|
|
21
|
-
});
|
|
22
|
-
}, this);
|
|
23
|
-
}
|
|
24
|
-
return retVal;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
layerEnter(base, svgElement, domElement) {
|
|
28
|
-
Layer.prototype.layerEnter.apply(this, arguments);
|
|
29
|
-
|
|
30
|
-
svgElement.append("defs").append("marker")
|
|
31
|
-
.attr("class", "marker")
|
|
32
|
-
.attr("id", this._id + "_arrowHead")
|
|
33
|
-
.attr("viewBox", "0 0 10 10")
|
|
34
|
-
.attr("refX", 10)
|
|
35
|
-
.attr("refY", 5)
|
|
36
|
-
.attr("markerWidth", 16)
|
|
37
|
-
.attr("markerHeight", 16)
|
|
38
|
-
.attr("markerUnits", "strokeWidth")
|
|
39
|
-
.attr("orient", "auto")
|
|
40
|
-
.append("polyline")
|
|
41
|
-
.attr("points", "0,0 10,5 0,10 1,5")
|
|
42
|
-
;
|
|
43
|
-
this._edgesTransform = svgElement.append("g");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
_edgesPaths;
|
|
47
|
-
layerUpdate(base) {
|
|
48
|
-
Layer.prototype.layerUpdate.apply(this, arguments);
|
|
49
|
-
|
|
50
|
-
this._edgesTransform
|
|
51
|
-
.style("opacity", this.opacity())
|
|
52
|
-
;
|
|
53
|
-
|
|
54
|
-
const edgesPaths = this._edgesTransform.selectAll(".dataEdge").data(this.visible() ? this.dataEdges : []);
|
|
55
|
-
this._edgesPaths = edgesPaths.enter().append("path")
|
|
56
|
-
.attr("class", "dataEdge")
|
|
57
|
-
.attr("marker-end", "url(#" + this._id + "_arrowHead)")
|
|
58
|
-
.merge(edgesPaths)
|
|
59
|
-
.attr("d", base._d3GeoPath)
|
|
60
|
-
;
|
|
61
|
-
edgesPaths.exit().remove();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
layerZoomed(base) {
|
|
65
|
-
Layer.prototype.layerZoomed.apply(this, arguments);
|
|
66
|
-
this._edgesPaths
|
|
67
|
-
.attr("stroke-width", `${0.5 / base.zoomScale()}px`)
|
|
68
|
-
;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
Lines.prototype._class += " map_Lines";
|
|
72
|
-
|
|
73
|
-
export interface Lines {
|
|
74
|
-
opacity(): number;
|
|
75
|
-
opacity(_: number): this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
Lines.prototype.publish("opacity", 1.0, "number", "Opacity", null, { tags: ["Advanced"] });
|
|
1
|
+
import { Layer } from "./Layer.ts";
|
|
2
|
+
|
|
3
|
+
import "../src/Lines.css";
|
|
4
|
+
|
|
5
|
+
export class Lines extends Layer {
|
|
6
|
+
dataEdges;
|
|
7
|
+
_edgesTransform;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
data(_) {
|
|
14
|
+
const retVal = Layer.prototype.data.apply(this, arguments);
|
|
15
|
+
if (arguments.length) {
|
|
16
|
+
this.dataEdges = [];
|
|
17
|
+
_.forEach(function (row) {
|
|
18
|
+
this.dataEdges.push({
|
|
19
|
+
type: "LineString",
|
|
20
|
+
coordinates: [[row[1], row[0]], [row[3], row[2]]]
|
|
21
|
+
});
|
|
22
|
+
}, this);
|
|
23
|
+
}
|
|
24
|
+
return retVal;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
layerEnter(base, svgElement, domElement) {
|
|
28
|
+
Layer.prototype.layerEnter.apply(this, arguments);
|
|
29
|
+
|
|
30
|
+
svgElement.append("defs").append("marker")
|
|
31
|
+
.attr("class", "marker")
|
|
32
|
+
.attr("id", this._id + "_arrowHead")
|
|
33
|
+
.attr("viewBox", "0 0 10 10")
|
|
34
|
+
.attr("refX", 10)
|
|
35
|
+
.attr("refY", 5)
|
|
36
|
+
.attr("markerWidth", 16)
|
|
37
|
+
.attr("markerHeight", 16)
|
|
38
|
+
.attr("markerUnits", "strokeWidth")
|
|
39
|
+
.attr("orient", "auto")
|
|
40
|
+
.append("polyline")
|
|
41
|
+
.attr("points", "0,0 10,5 0,10 1,5")
|
|
42
|
+
;
|
|
43
|
+
this._edgesTransform = svgElement.append("g");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_edgesPaths;
|
|
47
|
+
layerUpdate(base) {
|
|
48
|
+
Layer.prototype.layerUpdate.apply(this, arguments);
|
|
49
|
+
|
|
50
|
+
this._edgesTransform
|
|
51
|
+
.style("opacity", this.opacity())
|
|
52
|
+
;
|
|
53
|
+
|
|
54
|
+
const edgesPaths = this._edgesTransform.selectAll(".dataEdge").data(this.visible() ? this.dataEdges : []);
|
|
55
|
+
this._edgesPaths = edgesPaths.enter().append("path")
|
|
56
|
+
.attr("class", "dataEdge")
|
|
57
|
+
.attr("marker-end", "url(#" + this._id + "_arrowHead)")
|
|
58
|
+
.merge(edgesPaths)
|
|
59
|
+
.attr("d", base._d3GeoPath)
|
|
60
|
+
;
|
|
61
|
+
edgesPaths.exit().remove();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
layerZoomed(base) {
|
|
65
|
+
Layer.prototype.layerZoomed.apply(this, arguments);
|
|
66
|
+
this._edgesPaths
|
|
67
|
+
.attr("stroke-width", `${0.5 / base.zoomScale()}px`)
|
|
68
|
+
;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
Lines.prototype._class += " map_Lines";
|
|
72
|
+
|
|
73
|
+
export interface Lines {
|
|
74
|
+
opacity(): number;
|
|
75
|
+
opacity(_: number): this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Lines.prototype.publish("opacity", 1.0, "number", "Opacity", null, { tags: ["Advanced"] });
|
package/src/OpenStreet.css
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
.map_OpenStreet .background {
|
|
2
|
-
fill: white;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.map_OpenStreet .graticule {
|
|
6
|
-
fill: none;
|
|
7
|
-
stroke: #777;
|
|
8
|
-
stroke-width: .5px;
|
|
9
|
-
stroke-opacity: .5;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.map_Layered .vector {
|
|
13
|
-
fill: none;
|
|
14
|
-
stroke: navy;
|
|
15
|
-
stroke-linejoin: round;
|
|
1
|
+
.map_OpenStreet .background {
|
|
2
|
+
fill: white;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.map_OpenStreet .graticule {
|
|
6
|
+
fill: none;
|
|
7
|
+
stroke: #777;
|
|
8
|
+
stroke-width: .5px;
|
|
9
|
+
stroke-opacity: .5;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.map_Layered .vector {
|
|
13
|
+
fill: none;
|
|
14
|
+
stroke: navy;
|
|
15
|
+
stroke-linejoin: round;
|
|
16
16
|
}
|