@devgateway/dvz-ui-react 1.9.6 → 1.9.7
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/dist/cjs/embeddable/common/MapTooltip.js +1 -1
- package/dist/cjs/embeddable/map/MapDataFrame.js +1 -1
- package/dist/cjs/embeddable/map/index.js +2 -2
- package/dist/cjs/embeddable/map/map.js +4 -4
- package/dist/cjs/embeddable/map/mapHelpers.js +1 -0
- package/dist/esm/embeddable/common/MapTooltip.js +26 -22
- package/dist/esm/embeddable/map/MapDataFrame.js +152 -18
- package/dist/esm/embeddable/map/index.js +209 -198
- package/dist/esm/embeddable/map/map.js +602 -918
- package/dist/esm/embeddable/map/mapHelpers.js +243 -0
- package/dist/types/embeddable/map/map.d.ts +2 -1
- package/dist/types/embeddable/map/mapHelpers.d.ts +55 -0
- package/package.json +1 -1
|
@@ -1,164 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { Container as U, Segment as Q, Dimmer as ee, Loader as te, Message as N, Icon as E, Popup as se, Grid as S } from "semantic-ui-react";
|
|
8
|
-
import V from "react";
|
|
9
|
-
import * as ie from "topojson-client";
|
|
10
|
-
import oe from "./legend.js";
|
|
1
|
+
import { jsxs as b, Fragment as Ke, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { injectIntl as nr, FormattedMessage as ar } from "react-intl";
|
|
3
|
+
import * as c from "d3";
|
|
4
|
+
import { Icon as te, Popup as or, Message as xe, Container as Qe, Segment as sr, Dimmer as ir, Loader as cr, Grid as Fe } from "semantic-ui-react";
|
|
5
|
+
import { useState as re, useRef as L, useEffect as et } from "react";
|
|
6
|
+
import ur from "./legend.js";
|
|
11
7
|
import { formatContent as k } from "../common/MapTooltip.js";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { Config as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"#ff0000"
|
|
106
|
-
],
|
|
107
|
-
blues: [
|
|
108
|
-
"#e6eeff",
|
|
109
|
-
"#ccddff",
|
|
110
|
-
"#b3ccff",
|
|
111
|
-
"#99bbff",
|
|
112
|
-
"#80aaff",
|
|
113
|
-
"#6699ff",
|
|
114
|
-
"#4d88ff",
|
|
115
|
-
"#3377ff",
|
|
116
|
-
"#1a66ff",
|
|
117
|
-
"#0055ff"
|
|
118
|
-
]
|
|
119
|
-
}, de = ["mobile", "tablet", "midTablet"].includes(
|
|
120
|
-
T()
|
|
121
|
-
), $ = ["mobile", "tablet"].includes(T());
|
|
122
|
-
class ue extends V.Component {
|
|
123
|
-
constructor(e) {
|
|
124
|
-
var s;
|
|
125
|
-
super(e);
|
|
126
|
-
H(this, "handleScroll", () => {
|
|
127
|
-
let e = null;
|
|
128
|
-
clearTimeout(e), e = setTimeout(() => {
|
|
129
|
-
g.select(this.getMapId()).selectAll(".map-labels-container").size() > 0 || this.updateFeatures(this.getFeatures(), !1);
|
|
130
|
-
}, 300);
|
|
131
|
-
});
|
|
132
|
-
this.mapContainer = V.createRef(), this.state = { mainLayer: null, layers: null }, this.classColor = this.classColor.bind(this), this.featuresZoom = this.featuresZoom.bind(this), this.fullView = this.fullView.bind(this), this.onZoomIn = this.onZoomIn.bind(this), this.onZoomOut = this.onZoomOut.bind(this), this.onReset = this.onReset.bind(this), this.onClick = this.onClick.bind(this), this.showTooltip = this.showTooltip.bind(this), this.mousemove = this.mousemove.bind(this), this.mouseout = this.mouseout.bind(this), this.updateFeatures = this.updateFeatures.bind(this), this.d3Map = this.d3Map.bind(this), this.getFeatures = this.getFeatures.bind(this), this.boundingExtent = this.boundingExtent.bind(this), this.getMapId = this.getMapId.bind(this), this.zoomed = this.zoomed.bind(this), this.zoomEnd = this.zoomEnd.bind(this), this.drawPoints = this.drawPoints.bind(this), this.extractFeatures = this.extractFeatures.bind(this), this.getLayers = this.getLayers.bind(this), this.onPointClick = this.onPointClick.bind(this), this.onPolygonClick = this.onPolygonClick.bind(this), this.getCenter = this.getCenter.bind(this), this.mapPosition = null, this.zooming = !1, this.translateValue = pe[T()], this.projection = g.geoMercator().scale(e.scale).center(e.center).translate([this.getWidth() / this.translateValue, this.getHeight() / 2]), this.path = g.geoPath().projection(this.projection), this.zoom = g.zoom().scaleExtent([1, 16]).on("zoom", this.zoomed).on("end", this.zoomEnd), this.centered = null, this.state = {
|
|
133
|
-
selectedMeasure: e.transformedData && e.transformedData.measures && e.transformedData.measures.length > 1 ? e.transformedData.measures[0] : null,
|
|
134
|
-
generatedBreaks: [],
|
|
135
|
-
selectedPolygon: null,
|
|
136
|
-
layersLoading: !1
|
|
137
|
-
}, this.metadataTypes = ((s = e.transformedData) == null ? void 0 : s.types) || [];
|
|
138
|
-
}
|
|
139
|
-
componentDidMount() {
|
|
140
|
-
window.addEventListener("scroll", this.handleScroll, { passive: !0 }), window.addEventListener("touchmove", this.handleScroll, { passive: !0 }), this.loadLayers(), this.tooltip = g.select("body").append("div").style("position", "absolute").style("visibility", "hidden").style("pointer-events", "none"), console.log("Map props", this.metadataTypes);
|
|
8
|
+
import N from "../../utils/deviceType.js";
|
|
9
|
+
import { deviceTranslateMap as pr, getFilters as we, deviceMapHeight as dr, deviceMapWidth as tt, getHighlightedLocationColor as mr, getTranslatedItemLabel as fr, SHOW_ALL as rt, SHOW_IF_HAS_DATA as lt, LOCATION as nt, generateBreaks as gr, fillColor as hr, classColor as yr, getTranslatedLocationName as Ae, getLabelBoxWidth as vr, getLabelBoxHeight as br, createLabel as Lr, extractFeatures as xr } from "./mapHelpers.js";
|
|
10
|
+
import { Config as Fr } from "../../conf/index.js";
|
|
11
|
+
const wr = ["mobile", "tablet", "midTablet"].includes(
|
|
12
|
+
N()
|
|
13
|
+
), at = ["mobile", "tablet"].includes(N());
|
|
14
|
+
function Ar(O) {
|
|
15
|
+
const {
|
|
16
|
+
unique: Me,
|
|
17
|
+
editing: j,
|
|
18
|
+
source: Te,
|
|
19
|
+
center: le,
|
|
20
|
+
scale: ke,
|
|
21
|
+
height: Ne,
|
|
22
|
+
width: ot,
|
|
23
|
+
topoJSONField: st,
|
|
24
|
+
mappingField: y,
|
|
25
|
+
transformedData: u,
|
|
26
|
+
legendBreaks: Ee,
|
|
27
|
+
mapLabelField: x,
|
|
28
|
+
mapLabelShowValue: ne,
|
|
29
|
+
showOverallValue: ze,
|
|
30
|
+
measureSelectorLabel: Ie,
|
|
31
|
+
valueFormat: Ce,
|
|
32
|
+
autoGenerateBreaks: De,
|
|
33
|
+
showNoDataLabel: Pe,
|
|
34
|
+
numberOfBreaks: it,
|
|
35
|
+
colorScheme: ct,
|
|
36
|
+
symbols: Se,
|
|
37
|
+
tooltipTheme: ut,
|
|
38
|
+
labelFontSize: K,
|
|
39
|
+
labelFontColor: Oe,
|
|
40
|
+
labelFontWeight: pt,
|
|
41
|
+
legendFontSize: dt,
|
|
42
|
+
customTooltips: mt,
|
|
43
|
+
tooltipFontSize: ft,
|
|
44
|
+
showAdminUnitLabel: ae,
|
|
45
|
+
mapNoDataColor: We,
|
|
46
|
+
mapBoundaryColor: gt,
|
|
47
|
+
mapFocusBoundaryColor: ht,
|
|
48
|
+
highlightedLocation: C,
|
|
49
|
+
tooltipFormat: Re,
|
|
50
|
+
showNoDataTooltip: yt,
|
|
51
|
+
fields: vt,
|
|
52
|
+
mapContainerBgColor: bt,
|
|
53
|
+
mapPosition: h,
|
|
54
|
+
mainLayerId: W,
|
|
55
|
+
enabledLayers: D,
|
|
56
|
+
pointLabelColor: Lt,
|
|
57
|
+
pointLabelFormat: xt,
|
|
58
|
+
highlightedLocLabelFormat: Ft,
|
|
59
|
+
mapType: H,
|
|
60
|
+
defaultPointColor: Be,
|
|
61
|
+
zoomOnFilter: wt,
|
|
62
|
+
zoomOnFilterField: P,
|
|
63
|
+
noDataText: At,
|
|
64
|
+
labelsExclusionList: oe,
|
|
65
|
+
showShadingLayerLabels: _e,
|
|
66
|
+
appliedFilters: m,
|
|
67
|
+
intl: F,
|
|
68
|
+
legendTitle: Mt,
|
|
69
|
+
nationalAverageLabel: Tt,
|
|
70
|
+
zoomEnabled: se,
|
|
71
|
+
showTooltip: ie
|
|
72
|
+
} = O;
|
|
73
|
+
console.log("Map props:", O);
|
|
74
|
+
const [R, kt] = re(
|
|
75
|
+
() => u && u.measures && u.measures.length > 1 ? u.measures[0] : null
|
|
76
|
+
), [$, Nt] = re(null), [je, ce] = re(!1), [B, ue] = re(null), pe = L(null), w = L(null), v = L(null), U = L(null), A = L(null), He = L(null), E = L(null), $e = L(!1), de = L(null), me = L(null), M = L({}), fe = L(null), J = (u == null ? void 0 : u.types) || [];
|
|
77
|
+
function ge() {
|
|
78
|
+
return pe.current ? pe.current.offsetWidth : ot;
|
|
79
|
+
}
|
|
80
|
+
function he() {
|
|
81
|
+
return Ne;
|
|
82
|
+
}
|
|
83
|
+
A.current === null && (A.current = c.zoom().scaleExtent([1, 16]).on("zoom", (e) => M.current.zoomed(e)).on("end", (e) => M.current.zoomEnd(e))), v.current === null && (He.current = pr[N()], v.current = c.geoMercator().scale(ke).center(le).translate([ge() / He.current, he() / 2]), U.current = c.geoPath().projection(v.current));
|
|
84
|
+
function g() {
|
|
85
|
+
return ".map.wrapper." + Me;
|
|
86
|
+
}
|
|
87
|
+
function z() {
|
|
88
|
+
let e = R;
|
|
89
|
+
return !e && u && u.measures && u.measures.length > 1 && (e = u.measures[0]), e;
|
|
90
|
+
}
|
|
91
|
+
function Ue() {
|
|
92
|
+
return B && B.length > 0 ? B.map((t) => {
|
|
93
|
+
const o = D.find((n) => n.id == t.id);
|
|
94
|
+
return t.index = o ? o.index : 0, t;
|
|
95
|
+
}).sort((t, o) => parseInt(t.index) < parseInt(o.index) ? 1 : parseInt(t.index) > parseInt(o.index) ? -1 : 0) : [];
|
|
96
|
+
}
|
|
97
|
+
function Et() {
|
|
98
|
+
const e = Ue();
|
|
99
|
+
let t;
|
|
100
|
+
return e && (t = e.filter((o) => o.id == W || o.id == null)[0] || e[0]), t ? t.data : null;
|
|
141
101
|
}
|
|
142
|
-
|
|
143
|
-
|
|
102
|
+
function Ve(e) {
|
|
103
|
+
return xr(e, st);
|
|
144
104
|
}
|
|
145
|
-
|
|
146
|
-
|
|
105
|
+
function X() {
|
|
106
|
+
const e = Et(), t = Ue();
|
|
107
|
+
if (e) {
|
|
108
|
+
let o = [];
|
|
109
|
+
try {
|
|
110
|
+
o = Ve(e), o.map((l) => {
|
|
111
|
+
l.properties.layerId = W;
|
|
112
|
+
const r = t.find(
|
|
113
|
+
(a) => String(a.id) === String(W)
|
|
114
|
+
);
|
|
115
|
+
return r && (l.properties.layerMappingField = r.layerMappingField, l.properties.layerDatasource = r.layerDatasource, l.properties.layerApiField = r.layerApiField, l.properties.layerLocale = r.layerLocale, l.properties.displayLayerLabels = r.displayLayerLabels), D.forEach((a) => {
|
|
116
|
+
String(a.id) == W && Object.keys(a || {}).forEach((s) => {
|
|
117
|
+
l.properties[s] = a[s];
|
|
118
|
+
});
|
|
119
|
+
}), l;
|
|
120
|
+
}), t && t.forEach((l) => {
|
|
121
|
+
if (l.id != W) {
|
|
122
|
+
let r = Ve(l.data);
|
|
123
|
+
r = r.map((a) => (a.properties.layerId = l.id, a.properties.layerMappingField = l.layerMappingField, a.properties.layerDatasource = l.layerDatasource, a.properties.layerApiField = l.layerApiField, a.properties.layerLocale = l.layerLocale, a.properties.displayLayerLabels = l.displayLayerLabels, a)), o = [...r, ...o];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
} catch (l) {
|
|
127
|
+
console.log("error updating features .." + l);
|
|
128
|
+
}
|
|
129
|
+
const n = o.filter((l) => l.properties != null);
|
|
130
|
+
let i = u.locationsData;
|
|
131
|
+
return u.measures && u.measures.length > 1 && (i = u.locationsData.filter(
|
|
132
|
+
(l) => l.measure === z()
|
|
133
|
+
)), n.map((l) => {
|
|
134
|
+
if (i) {
|
|
135
|
+
const r = i.find((a) => {
|
|
136
|
+
const s = a.label ? ("" + a.label).toLowerCase() : "", d = l.properties[y] ? l.properties[y].toLowerCase() : "";
|
|
137
|
+
return s === d;
|
|
138
|
+
});
|
|
139
|
+
if (r) {
|
|
140
|
+
let a = r.measure;
|
|
141
|
+
u.measureLabelMap && r.measure && u.measureLabelMap[r.measure] && (a = u.measureLabelMap[r.measure]), l.properties.value = r.value, l.properties.measure = r.measure, l.properties.measureLabel = a, l.properties.children = r.children, l.properties.variables = r.variables, l.properties.hasDataRow = !0, Object.keys(r).forEach((s) => {
|
|
142
|
+
l.properties[s] = r[s];
|
|
143
|
+
});
|
|
144
|
+
} else
|
|
145
|
+
l.properties.value = null, l.properties.measure = null, l.properties.children = null, l.properties.measureLabel = null, l.properties.hasDataRow = !1;
|
|
146
|
+
}
|
|
147
|
+
}), n;
|
|
148
|
+
}
|
|
149
|
+
return [];
|
|
147
150
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
o.push(
|
|
157
|
-
new Promise((a, n) => {
|
|
158
|
-
g.json(re.REACT_APP_WP_API + "/wp/v2/media/" + t.id).then((l) => {
|
|
159
|
-
a({
|
|
151
|
+
function Ge() {
|
|
152
|
+
if (ue([]), ce(!0), D && D.length > 0) {
|
|
153
|
+
const e = [];
|
|
154
|
+
D.forEach((t) => {
|
|
155
|
+
e.push(
|
|
156
|
+
new Promise((o) => {
|
|
157
|
+
c.json(Fr.REACT_APP_WP_API + "/wp/v2/media/" + t.id).then((n) => {
|
|
158
|
+
o({
|
|
160
159
|
id: t.id,
|
|
161
|
-
url:
|
|
160
|
+
url: n.source_url,
|
|
162
161
|
index: t.index,
|
|
163
162
|
layerMappingField: t.layerMappingField,
|
|
164
163
|
layerDatasource: t.datasource,
|
|
@@ -166,8 +165,8 @@ class ue extends V.Component {
|
|
|
166
165
|
layerLocale: t.locale,
|
|
167
166
|
displayLayerLabels: t.displayLayerLabels
|
|
168
167
|
});
|
|
169
|
-
}).catch(function(
|
|
170
|
-
|
|
168
|
+
}).catch(function() {
|
|
169
|
+
o({
|
|
171
170
|
id: t.id,
|
|
172
171
|
url: null,
|
|
173
172
|
index: t.index,
|
|
@@ -180,15 +179,15 @@ class ue extends V.Component {
|
|
|
180
179
|
});
|
|
181
180
|
})
|
|
182
181
|
);
|
|
183
|
-
}), Promise.all(
|
|
184
|
-
const
|
|
182
|
+
}), Promise.all(e).then((t) => {
|
|
183
|
+
const o = [];
|
|
185
184
|
t.forEach((n) => {
|
|
186
|
-
n.url &&
|
|
187
|
-
new Promise((
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
n.url && o.push(
|
|
186
|
+
new Promise((i) => {
|
|
187
|
+
c.json(n.url).then((l) => {
|
|
188
|
+
i({
|
|
190
189
|
id: n.id,
|
|
191
|
-
data:
|
|
190
|
+
data: l,
|
|
192
191
|
index: n.index,
|
|
193
192
|
layerMappingField: n.layerMappingField,
|
|
194
193
|
layerDatasource: n.layerDatasource,
|
|
@@ -199,855 +198,540 @@ class ue extends V.Component {
|
|
|
199
198
|
});
|
|
200
199
|
})
|
|
201
200
|
);
|
|
202
|
-
}), Promise.all(
|
|
203
|
-
|
|
204
|
-
layers: n,
|
|
205
|
-
layersLoading: !1
|
|
206
|
-
});
|
|
201
|
+
}), Promise.all(o).then((n) => {
|
|
202
|
+
ue(n), ce(!1);
|
|
207
203
|
});
|
|
208
204
|
});
|
|
209
205
|
} else
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
],
|
|
225
|
-
layersLoading: !1
|
|
226
|
-
});
|
|
206
|
+
c.json(Te).then((e) => {
|
|
207
|
+
ue([
|
|
208
|
+
{
|
|
209
|
+
id: null,
|
|
210
|
+
url: Te,
|
|
211
|
+
data: e,
|
|
212
|
+
index: 0,
|
|
213
|
+
layerMappingField: null,
|
|
214
|
+
layerDatasource: null,
|
|
215
|
+
layerApiField: null,
|
|
216
|
+
layerLocale: null,
|
|
217
|
+
displayLayerLabels: !1
|
|
218
|
+
}
|
|
219
|
+
]), ce(!1);
|
|
227
220
|
});
|
|
228
221
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
let o;
|
|
232
|
-
return e && (o = e.filter(
|
|
233
|
-
(t) => t.id == s || t.id == null
|
|
234
|
-
)[0] || e[0]), o ? o.data : null;
|
|
222
|
+
function zt(e) {
|
|
223
|
+
c.select(g()).select("svg").selectAll("circle").attr("r", e.k > 1 ? 6 / e.k : 6);
|
|
235
224
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (h) {
|
|
239
|
-
const v = [], c = [];
|
|
240
|
-
d && Object.keys(d).forEach((f) => {
|
|
241
|
-
d[f] != null && d[f] instanceof Array && v.push(
|
|
242
|
-
...d[f].filter(
|
|
243
|
-
(y) => y != Number.MIN_SAFE_INTEGER
|
|
244
|
-
)
|
|
245
|
-
);
|
|
246
|
-
}), p && Object.keys(p).forEach((f) => {
|
|
247
|
-
p[f] != null && p[f] instanceof Array && c.push(
|
|
248
|
-
...p[f].filter((y) => y != Number.MIN_SAFE_INTEGER)
|
|
249
|
-
);
|
|
250
|
-
}), v.length > 0 && c.length == 0 && this.onReset();
|
|
251
|
-
}
|
|
252
|
-
this.tooltip.style("visibility", "hidden"), e.enabledLayers.length != this.props.enabledLayers.length && this.loadLayers();
|
|
253
|
-
const u = this.getFeatures();
|
|
254
|
-
e.center !== this.props.center && (this.mapPosition = null, this.projection.scale(this.props.scale).center(this.props.center).translate([this.getWidth() / 2, this.getHeight() / 2]));
|
|
255
|
-
const m = this.filterUpdated(e, s);
|
|
256
|
-
this.d3Map(u, m), t && l && (l != e.transformedData || t != s.layers || o != s.selectedMeasure || a != s.selectedPolygon || n != s.mainLayer || e.mainLayerId !== this.props.mainLayerId || JSON.stringify(e.enabledLayers) != JSON.stringify(this.props.enabledLayers)) && this.updateFeatures(this.getFeatures(), m);
|
|
257
|
-
}
|
|
258
|
-
getHeight() {
|
|
259
|
-
return this.props.height;
|
|
260
|
-
}
|
|
261
|
-
getWidth() {
|
|
262
|
-
return this.mapContainer.current ? this.mapContainer.current.offsetWidth : this.props.width;
|
|
263
|
-
}
|
|
264
|
-
boundingExtent(e) {
|
|
265
|
-
let s, i, o, t;
|
|
266
|
-
for (const a in e) {
|
|
267
|
-
const [[n, l], [r, h]] = this.path.bounds(e[a]);
|
|
268
|
-
(n < s || s == null) && (s = n), (r > i || i == null) && (i = r), (l < o || o == null) && (o = l), (h > t || t == null) && (t = h);
|
|
269
|
-
}
|
|
270
|
-
return [
|
|
271
|
-
[s, o],
|
|
272
|
-
[i, t]
|
|
273
|
-
];
|
|
225
|
+
function _(e) {
|
|
226
|
+
return vr(e, x);
|
|
274
227
|
}
|
|
275
|
-
|
|
276
|
-
|
|
228
|
+
function Q() {
|
|
229
|
+
return br(ne);
|
|
277
230
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
231
|
+
function ye(e) {
|
|
232
|
+
return e.properties.LABEL_LATITUDE && e.properties.LABEL_LONGITUDE ? v.current([
|
|
233
|
+
e.properties.LABEL_LONGITUDE,
|
|
234
|
+
e.properties.LABEL_LATITUDE
|
|
235
|
+
]) : U.current.centroid(e);
|
|
236
|
+
}
|
|
237
|
+
function It(e) {
|
|
238
|
+
c.select(g()).selectAll(".map-labels-container").each((t, o, n) => {
|
|
239
|
+
const i = c.select(n[o]), l = i.select("div"), r = e.k > 1 ? e.k : 1, a = K / r;
|
|
240
|
+
l.style("font-size", `${a}px`);
|
|
241
|
+
const s = ye(t), d = _(t) / r, f = s[0] - d / 2, T = e.k > 1 ? 10 / e.k : 10, S = s[1] - T;
|
|
242
|
+
i.attr("x", f).attr("y", S).attr("width", _(t) / r).attr("height", Q() / r);
|
|
285
243
|
});
|
|
286
244
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
a.attr("x", u).attr("y", m).attr("width", p).attr("height", d);
|
|
245
|
+
function Ct(e) {
|
|
246
|
+
c.select(g()).selectAll(".point-labels-container").each((t, o, n) => {
|
|
247
|
+
const i = c.select(n[o]), l = i.select("div"), r = e.k > 1 ? e.k : 1, a = K / r;
|
|
248
|
+
l.style("font-size", `${a}px`);
|
|
249
|
+
const s = v.current([
|
|
250
|
+
t.geometry.coordinates[1],
|
|
251
|
+
t.geometry.coordinates[0]
|
|
252
|
+
]), d = (_(t) + 20) / r, f = Q() / r, T = s[0] - d / 2, S = s[1] - f / 2;
|
|
253
|
+
i.attr("x", T).attr("y", S).attr("width", d).attr("height", f);
|
|
297
254
|
});
|
|
298
255
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.tooltip.style("visibility", "hidden");
|
|
304
|
-
const s = e.transform;
|
|
305
|
-
g.select(this.getMapId()).select("svg").select("g").attr("transform", s), this.resizeCircles(s), this.resizeLabels(s), this.resizePointLabels(s);
|
|
256
|
+
function Dt(e) {
|
|
257
|
+
w.current.style("visibility", "hidden");
|
|
258
|
+
const t = e.transform;
|
|
259
|
+
c.select(g()).select("svg").select("g").attr("transform", t), zt(t), It(t), Ct(t);
|
|
306
260
|
}
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
{ type: "map", value: JSON.stringify(
|
|
261
|
+
function Pt(e) {
|
|
262
|
+
const t = e.transform;
|
|
263
|
+
E.current = { k: t.k, x: t.x, y: t.y }, j && window.parent.postMessage(
|
|
264
|
+
{ type: "map", value: JSON.stringify(E.current) },
|
|
311
265
|
"*"
|
|
312
266
|
);
|
|
313
267
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
)
|
|
268
|
+
function St() {
|
|
269
|
+
const e = c.select(g()).select("svg");
|
|
270
|
+
e.select("g").selectAll(".active").attr("class", function() {
|
|
271
|
+
return c.select(this).attr("class").replace(/background/gi, "");
|
|
272
|
+
});
|
|
273
|
+
let o = c.zoomIdentity;
|
|
274
|
+
h && !j ? o = o.translate(h.x, h.y).scale(h.k) : o = o.translate(0, 0).scale(1), e.transition().duration(300).call(A.current.transform, o);
|
|
319
275
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (s && e && e.length > 0) {
|
|
323
|
-
const a = e.filter((r) => r.properties && r.properties.value != null).map((r) => r.properties.value.toFixed(2)), n = [];
|
|
324
|
-
a.forEach((r) => {
|
|
325
|
-
if (r > 0) {
|
|
326
|
-
const h = r * 0.99, p = r * 1.01;
|
|
327
|
-
n.indexOf(h) === -1 && n.push(h), n.indexOf(p) === -1 && n.push(p);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
const l = he[o];
|
|
331
|
-
if (n.length > 0) {
|
|
332
|
-
const r = new ae(n);
|
|
333
|
-
r.setPrecision(2);
|
|
334
|
-
const h = n.length > 1 ? n.length - 1 : n.length;
|
|
335
|
-
return r.getJenks(Math.min(i, h)), r.ranges.forEach((p, d) => {
|
|
336
|
-
const u = {};
|
|
337
|
-
u.min = parseFloat(p.substr(0, p.indexOf("-") - 1)) + (d > 0 ? 0.01 : 0), u.max = parseFloat(
|
|
338
|
-
p.substr(p.indexOf("-") + 2, p.length)
|
|
339
|
-
), u.color = l[d], t.push(u);
|
|
340
|
-
}), t;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return t;
|
|
276
|
+
function Je() {
|
|
277
|
+
E.current = null, w.current.style("visibility", "hidden"), St();
|
|
344
278
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
279
|
+
function Ot() {
|
|
280
|
+
c.select(g()).select("svg").transition().call(A.current.scaleBy, 1.5);
|
|
281
|
+
}
|
|
282
|
+
function Wt() {
|
|
283
|
+
c.select(g()).select("svg").transition().call(A.current.scaleBy, 0.6667);
|
|
284
|
+
}
|
|
285
|
+
function Z() {
|
|
286
|
+
if (De) {
|
|
287
|
+
const e = X();
|
|
288
|
+
return gr(e, {
|
|
289
|
+
autoGenerateBreaks: De,
|
|
290
|
+
numberOfBreaks: it,
|
|
291
|
+
colorScheme: ct
|
|
292
|
+
});
|
|
350
293
|
} else {
|
|
351
|
-
let
|
|
352
|
-
return
|
|
353
|
-
if (
|
|
354
|
-
const
|
|
355
|
-
return
|
|
356
|
-
if (
|
|
357
|
-
const r =
|
|
358
|
-
return r.join(",").indexOf(
|
|
294
|
+
let e = Ee;
|
|
295
|
+
return z() && (e = Ee.filter((t) => t.measure === z()).filter((t) => {
|
|
296
|
+
if (t.filters && t.filters.length > 0 && m && JSON.stringify(m) !== "{}") {
|
|
297
|
+
const n = Object.keys(m);
|
|
298
|
+
return t.filters.filter((l) => {
|
|
299
|
+
if (n.indexOf(l.field) != -1) {
|
|
300
|
+
const r = m[l.field], a = l.values;
|
|
301
|
+
return r.join(",").indexOf(a) != -1;
|
|
359
302
|
}
|
|
360
303
|
return !1;
|
|
361
304
|
}).length > 0;
|
|
362
305
|
}
|
|
363
306
|
return !0;
|
|
364
|
-
})),
|
|
307
|
+
})), e;
|
|
365
308
|
}
|
|
366
309
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
if (e.properties.value != null && (o && e.properties.layerId === o || !o)) {
|
|
376
|
-
const n = s.find((l) => {
|
|
377
|
-
if (l.min != null && l.max != null)
|
|
378
|
-
return e.properties.value >= l.min && e.properties.value <= l.max;
|
|
379
|
-
if (l.min != null)
|
|
380
|
-
return e.properties.value >= l.min;
|
|
381
|
-
if (l.max != null)
|
|
382
|
-
return e.properties.value <= l.max;
|
|
383
|
-
});
|
|
384
|
-
return n && n.color ? n.color : i;
|
|
385
|
-
}
|
|
386
|
-
const a = this.props.enabledLayers.filter(
|
|
387
|
-
(n) => n.id === e.properties.layerId
|
|
388
|
-
)[0];
|
|
389
|
-
return a && a.bgColor && a.bgColor != "undefined" ? a.bgColor : i;
|
|
390
|
-
}
|
|
391
|
-
setValues() {
|
|
392
|
-
const e = this.getFeatures();
|
|
393
|
-
g.select(this.getMapId()).select("svg").select("g").selectAll("path").data(e).join("path").attr("d", this.path);
|
|
310
|
+
function ve(e, t) {
|
|
311
|
+
return hr(e, t, {
|
|
312
|
+
mapNoDataColor: We,
|
|
313
|
+
mainLayerId: W,
|
|
314
|
+
enabledLayers: D,
|
|
315
|
+
selectedMeasure: R
|
|
316
|
+
});
|
|
394
317
|
}
|
|
395
|
-
|
|
396
|
-
return
|
|
397
|
-
e
|
|
398
|
-
|
|
399
|
-
|
|
318
|
+
function Rt(e) {
|
|
319
|
+
return Lr(
|
|
320
|
+
e,
|
|
321
|
+
{
|
|
322
|
+
mapLabelField: x,
|
|
323
|
+
mapLabelShowValue: ne,
|
|
324
|
+
intl: F,
|
|
325
|
+
valueFormat: Ce,
|
|
326
|
+
showNoDataLabel: Pe,
|
|
327
|
+
showAdminUnitLabel: ae,
|
|
328
|
+
noDataText: At,
|
|
329
|
+
selectedMeasure: z()
|
|
330
|
+
},
|
|
331
|
+
J,
|
|
332
|
+
k
|
|
333
|
+
);
|
|
400
334
|
}
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
...e.filter((n) =>
|
|
404
|
-
...e.filter((n) =>
|
|
335
|
+
function Xe(e, t) {
|
|
336
|
+
const o = [
|
|
337
|
+
...e.filter((n) => C != n.properties[x]),
|
|
338
|
+
...e.filter((n) => C == n.properties[x])
|
|
405
339
|
];
|
|
406
|
-
|
|
340
|
+
_t(o), Bt(o), jt(o, t), Se.length > 0 && Ht(Se, o);
|
|
407
341
|
}
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
mapLabelShowValue: i,
|
|
412
|
-
intl: o,
|
|
413
|
-
valueFormat: t,
|
|
414
|
-
showNoDataLabel: a,
|
|
415
|
-
labelFontColor: n,
|
|
416
|
-
labelFontWeight: l,
|
|
417
|
-
labelFontSize: r,
|
|
418
|
-
showAdminUnitLabel: h,
|
|
419
|
-
mapType: p,
|
|
420
|
-
noDataText: d,
|
|
421
|
-
labelsExclusionList: u
|
|
422
|
-
} = this.props, m = g.select(this.getMapId()).select("svg").select("g");
|
|
423
|
-
if (m.selectAll(".map-labels-container").size() > 0) {
|
|
342
|
+
function Bt(e) {
|
|
343
|
+
const t = c.select(g()).select("svg").select("g");
|
|
344
|
+
if (t.selectAll(".map-labels-container").size() > 0) {
|
|
424
345
|
console.log("Labels already exist, skipping redraw...");
|
|
425
346
|
return;
|
|
426
347
|
}
|
|
427
|
-
|
|
428
|
-
e.filter((
|
|
429
|
-
).enter().append("foreignObject").attr("class", "map-labels-container").attr("x", (
|
|
430
|
-
const
|
|
431
|
-
if (
|
|
432
|
-
const
|
|
433
|
-
return
|
|
348
|
+
t.selectAll(".map-labels").data(
|
|
349
|
+
e.filter((n) => oe && oe.length > 0 ? !oe.includes(n.properties[x]) : !0)
|
|
350
|
+
).enter().append("foreignObject").attr("class", "map-labels-container").attr("x", (n) => {
|
|
351
|
+
const i = ye(n);
|
|
352
|
+
if (n.properties[x]) {
|
|
353
|
+
const l = _(n);
|
|
354
|
+
return i[0] - l / 2;
|
|
434
355
|
}
|
|
435
|
-
return
|
|
436
|
-
}).attr("y", (
|
|
356
|
+
return i[0];
|
|
357
|
+
}).attr("y", (n) => ye(n)[1] - 10).attr("width", (n) => _(n)).attr("height", (n) => Q()).attr("font-size", () => `${K}px`).attr("overflow", "visible").attr("opacity", 1).style("display", (n) => ae === rt || ae === lt && n.properties.hasDataRow || n.properties.displayLayerLabels ? "block" : "none").attr("pointer-events", H == "POINTS_MAP" ? "none" : "all").on("mouseover", V).on("mousemove", Y).on("mouseout", G).append("xhtml:div").style("font-size", () => `${K}px`).style("color", () => Oe).style("font-weight", () => pt).style("background-color", (n) => n.properties.hasDataRow && ne && (n.properties.value != null || n.properties.value == null && Pe) ? "#fff6e1" : "none").style("border-radius", () => "4px").style("line-height", "95%").style("text-align", "center").html((n) => Rt(n));
|
|
437
358
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return O(this.metadataTypes, t, e.properties.layerLocale);
|
|
442
|
-
}
|
|
443
|
-
return e.properties[s];
|
|
444
|
-
}
|
|
445
|
-
createLabel(e) {
|
|
446
|
-
const {
|
|
447
|
-
mapLabelField: s,
|
|
448
|
-
mapLabelShowValue: i,
|
|
449
|
-
intl: o,
|
|
450
|
-
valueFormat: t,
|
|
451
|
-
showNoDataLabel: a,
|
|
452
|
-
showAdminUnitLabel: n,
|
|
453
|
-
noDataText: l
|
|
454
|
-
} = this.props;
|
|
455
|
-
let r = "";
|
|
456
|
-
if (n == j || n == B && e.properties.hasDataRow || e.properties.displayLayerLabels) {
|
|
457
|
-
const h = e.properties.displayLayerLabels && e.properties.layerMappingField ? e.properties.layerMappingField : s, p = e.properties[h], d = e.properties.layerLocale || (o == null ? void 0 : o.locale);
|
|
458
|
-
r = O(this.metadataTypes, p, d);
|
|
459
|
-
const u = e.properties.abbrev;
|
|
460
|
-
if (r && r.length > ne && u && (r = u), i)
|
|
461
|
-
if (e.properties.value != null) {
|
|
462
|
-
const m = e.properties.variables || {};
|
|
463
|
-
r += "<br><span class='map-label-value'>" + k(
|
|
464
|
-
t,
|
|
465
|
-
{
|
|
466
|
-
value: e.properties.value,
|
|
467
|
-
measure: this.getSelectedMeasure(),
|
|
468
|
-
...m
|
|
469
|
-
},
|
|
470
|
-
o
|
|
471
|
-
) + "</span>";
|
|
472
|
-
} else
|
|
473
|
-
a == !0 && e.properties.value == null && e.properties.hasDataRow && (r += "<br><span class='map-label-value'>" + l + "</span>");
|
|
474
|
-
}
|
|
475
|
-
return r;
|
|
476
|
-
}
|
|
477
|
-
drawPolygons(e) {
|
|
478
|
-
const {
|
|
479
|
-
mapLabelField: s,
|
|
480
|
-
mapBoundaryColor: i,
|
|
481
|
-
mapFocusBoundaryColor: o,
|
|
482
|
-
highlightedLocation: t
|
|
483
|
-
} = this.props, a = this.getBreaks(), n = g.select(this.getMapId()).select("svg").select("g"), l = e.filter(
|
|
484
|
-
(r) => r.geometry && r.geometry && (r.geometry.type == "Polygon" || r.geometry.type == "MultiPolygon")
|
|
359
|
+
function _t(e) {
|
|
360
|
+
const t = Z(), o = c.select(g()).select("svg").select("g"), n = e.filter(
|
|
361
|
+
(i) => i.geometry && i.geometry && (i.geometry.type == "Polygon" || i.geometry.type == "MultiPolygon")
|
|
485
362
|
);
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
defaultPointColor: n,
|
|
495
|
-
appliedFilters: l,
|
|
496
|
-
zoomOnFilterField: r,
|
|
497
|
-
noDataText: h,
|
|
498
|
-
showShadingLayerLabels: p
|
|
499
|
-
} = this.props, d = g.select(this.getMapId()).select("svg").select("g");
|
|
500
|
-
let u = [];
|
|
501
|
-
if (a.pointsData) {
|
|
502
|
-
let c = this.state.selectedPolygon;
|
|
503
|
-
s && l && l[r] && (c = l[r]), u = a.pointsData.filter((f) => f.lat && f.lng && f.label == c).map((f) => ({
|
|
363
|
+
n.length > 0 && o.selectAll("path").data(n).join("path").attr("d", U.current).attr("fill", (i) => ve(i, t)).attr("stroke-width", (i) => C == i.properties[x] ? 1.2 : 0.4).attr("stroke", (i) => C == i.properties[x] ? ht : gt).on("click", Ut);
|
|
364
|
+
}
|
|
365
|
+
function jt(e, t) {
|
|
366
|
+
const o = c.select(g()).select("svg").select("g");
|
|
367
|
+
let n = [];
|
|
368
|
+
if (u.pointsData) {
|
|
369
|
+
let r = $;
|
|
370
|
+
t && m && m[P] && (r = m[P]), n = u.pointsData.filter((a) => a.lat && a.lng && a.label == r).map((a) => ({
|
|
504
371
|
properties: {
|
|
505
|
-
label:
|
|
506
|
-
lat:
|
|
507
|
-
lng:
|
|
508
|
-
value:
|
|
509
|
-
variables:
|
|
372
|
+
label: a.label,
|
|
373
|
+
lat: a.lat,
|
|
374
|
+
lng: a.lng,
|
|
375
|
+
value: a.value,
|
|
376
|
+
variables: a.variables
|
|
510
377
|
}
|
|
511
|
-
})),
|
|
512
|
-
f.properties.lng,
|
|
513
|
-
f.properties.lat
|
|
514
|
-
])[0]).attr("cy", (f) => this.projection([
|
|
515
|
-
f.properties.lng,
|
|
516
|
-
f.properties.lat
|
|
517
|
-
])[1]).attr("r", (f, y) => 2).style("stroke-width", 0.5).style("fill", (f, y) => n).on("mouseover", (f, y) => this.onPointClick(f, y)).on("mouseout", this.mouseout);
|
|
378
|
+
})), o.selectAll(".circle").data(n).enter().append("circle").attr("id", (a, s) => "circle" + s).attr("cx", (a) => v.current([a.properties.lng, a.properties.lat])[0]).attr("cy", (a) => v.current([a.properties.lng, a.properties.lat])[1]).attr("r", () => 2).style("stroke-width", 0.5).style("fill", () => Be).on("mouseover", (a, s) => $t(a, s)).on("mouseout", G);
|
|
518
379
|
}
|
|
519
|
-
const
|
|
520
|
-
let
|
|
521
|
-
|
|
522
|
-
(
|
|
523
|
-
)
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
)
|
|
542
|
-
|
|
543
|
-
}).on("mousemove",
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const
|
|
547
|
-
e.forEach((
|
|
548
|
-
if (
|
|
549
|
-
const
|
|
550
|
-
const
|
|
551
|
-
return
|
|
552
|
-
(
|
|
380
|
+
const i = Z();
|
|
381
|
+
let l = [];
|
|
382
|
+
_e == rt ? l = e.filter((r) => r.geometry && r.geometry.type == "Point") : _e == lt && (l = e.filter(
|
|
383
|
+
(r) => r.geometry && r.geometry.type == "Point" && r.properties.hasDataRow
|
|
384
|
+
)), l.length > 0 && o.selectAll(".point-labels").data(l).enter().append("foreignObject").attr("id", (r, a) => "point-label" + a).attr("class", "point-labels-container").attr("x", (r) => {
|
|
385
|
+
const a = _(r) + 20;
|
|
386
|
+
return v.current([
|
|
387
|
+
r.geometry.coordinates[1],
|
|
388
|
+
r.geometry.coordinates[0]
|
|
389
|
+
])[0] - a / 2;
|
|
390
|
+
}).attr("y", (r) => v.current([
|
|
391
|
+
r.geometry.coordinates[1],
|
|
392
|
+
r.geometry.coordinates[0]
|
|
393
|
+
])[1] - Q() / 2).attr("width", (r) => _(r) + 20).attr("height", () => "1px").attr("overflow", "visible").attr("font-size", "12px").style("opacity", 1).append("xhtml:div").style("color", () => Lt).style("font-weight", () => "bold").style("background-color", (r) => ve(r, i)).style("padding", () => "5px 3px 5px 3px").style("border-radius", () => "4px").style("line-height", "100%").style("text-align", "center").html(
|
|
394
|
+
(r) => k(
|
|
395
|
+
xt,
|
|
396
|
+
{
|
|
397
|
+
value: r.properties.value,
|
|
398
|
+
locationName: r.properties[x]
|
|
399
|
+
},
|
|
400
|
+
F
|
|
401
|
+
)
|
|
402
|
+
).on("mouseover", (r, a, s) => {
|
|
403
|
+
c.select(g()).select("svg").select("g").select("#point-label" + s).raise(), V(r, a);
|
|
404
|
+
}).on("mousemove", Y).on("mouseout", G);
|
|
405
|
+
}
|
|
406
|
+
function Ht(e, t) {
|
|
407
|
+
const o = c.select(g()).select("svg").select("g");
|
|
408
|
+
e.forEach((n) => {
|
|
409
|
+
if (n.field && n.image && n.values) {
|
|
410
|
+
const i = t.filter((r) => {
|
|
411
|
+
const a = nt == n.field ? y : "value", s = (r.properties[a] || (r.properties.variables ? r.properties.variables[a] : "")) + "", f = (n.values + "").split(",");
|
|
412
|
+
return r.properties.LATITUDE && r.properties.LONGITUDE && f.filter(
|
|
413
|
+
(T) => T.trim().toLowerCase() == s.trim().toLowerCase()
|
|
553
414
|
).length > 0;
|
|
554
|
-
}),
|
|
555
|
-
const
|
|
556
|
-
return !
|
|
557
|
-
(
|
|
415
|
+
}), l = t.filter((r) => {
|
|
416
|
+
const a = nt == n.field ? y : "value", s = (r.properties[a] || (r.properties.variables ? r.properties.variables[a] : "")) + "", f = (n.values + "").split(",");
|
|
417
|
+
return !r.properties.LATITUDE && !r.properties.LONGITUDE && f.filter(
|
|
418
|
+
(T) => T.trim().toLowerCase() == s.trim().toLowerCase()
|
|
558
419
|
).length > 0;
|
|
559
420
|
});
|
|
560
|
-
o.selectAll("image").data(
|
|
421
|
+
o.selectAll("image").data(i).enter().append("image").attr("width", 40).attr("height", 40).attr("class", "map-symbol").attr("xlink:href", "/" + n.image).attr(
|
|
422
|
+
"transform",
|
|
423
|
+
(r) => "translate(" + v.current([r.properties.LONGITUDE, r.properties.LATITUDE]) + ")"
|
|
424
|
+
).on("mouseover", V).on("mousemove", Y).on("mouseout", G), o.selectAll("image").data(l).enter().append("image").attr("width", 40).attr("height", 40).attr("class", "map-symbol").attr("xlink:href", "/" + n.image).attr("x", (r) => U.current.centroid(r)[0] - 20).attr("y", (r) => U.current.centroid(r)[1]).on("mouseover", V).on("mousemove", Y).on("mouseout", G);
|
|
561
425
|
}
|
|
562
426
|
});
|
|
563
427
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
this.zoom.transform,
|
|
583
|
-
g.zoomIdentity.translate(u[0], u[1]).scale(d)
|
|
584
|
-
) : o.transition().duration(450).call(
|
|
585
|
-
this.zoom.transform,
|
|
586
|
-
g.zoomIdentity.translate(u[0], u[1]).scale(d)
|
|
587
|
-
).on("end", i);
|
|
588
|
-
}
|
|
589
|
-
fullView() {
|
|
590
|
-
const { mapPosition: e, editing: s } = this.props, i = g.select(this.getMapId()).select("svg");
|
|
591
|
-
i.select("g").selectAll(".active").attr("class", function() {
|
|
592
|
-
return g.select(this).attr("class").replace(/background/gi, "");
|
|
593
|
-
});
|
|
594
|
-
let t = g.zoomIdentity;
|
|
595
|
-
e && !s ? t = t.translate(e.x, e.y).scale(e.k) : t = t.translate(0, 0).scale(1), i.transition().duration(300).call(this.zoom.transform, t);
|
|
596
|
-
}
|
|
597
|
-
showTooltip(e, s) {
|
|
598
|
-
let {
|
|
599
|
-
showTooltip: i,
|
|
600
|
-
zoomEnabled: o,
|
|
601
|
-
tooltipTheme: t,
|
|
602
|
-
customTooltips: a,
|
|
603
|
-
tooltipFontSize: n,
|
|
604
|
-
tooltipFormat: l,
|
|
605
|
-
intl: r,
|
|
606
|
-
mappingField: h,
|
|
607
|
-
showNoDataTooltip: p,
|
|
608
|
-
fields: d,
|
|
609
|
-
mapType: u,
|
|
610
|
-
noDataText: m
|
|
611
|
-
} = this.props;
|
|
612
|
-
if (o = !!["mobile", "tablet", "midTablet"].includes(
|
|
613
|
-
T()
|
|
614
|
-
), i && s.properties.value != null || i && p) {
|
|
615
|
-
g.select(this.getMapId()).select("svg").select("g").selectAll(".active").attr("class", (A) => A.properties[h] === s.properties[h] ? "focus" + (o ? " zoom-enabled" : "") : "active" + (o ? " zoom-enabled" : ""));
|
|
616
|
-
const f = l || `{locationName} %({value},2)
|
|
617
|
-
{label}: %({value},2)`, y = s.properties.variables || {}, I = {
|
|
618
|
-
...s.properties,
|
|
619
|
-
value: s.properties.value,
|
|
620
|
-
measure: this.getSelectedMeasure(),
|
|
621
|
-
measureLabel: s.properties.measureLabel,
|
|
622
|
-
locationName: this.getTranslatedLocationName(s, h, r),
|
|
623
|
-
label: this.getTranslatedLocationName(s, h, r),
|
|
624
|
-
...y
|
|
428
|
+
function V(e, t) {
|
|
429
|
+
console.log("Showing tooltip for data:", t);
|
|
430
|
+
const o = ["mobile", "tablet", "midTablet"].includes(
|
|
431
|
+
N()
|
|
432
|
+
);
|
|
433
|
+
if (ie && t.properties.value !== null || ie && yt) {
|
|
434
|
+
c.select(g()).select("svg").select("g").selectAll(".active").attr("class", (s) => s.properties[y] === t.properties[y] ? "focus" + (o ? " zoom-enabled" : "") : "active" + (o ? " zoom-enabled" : ""));
|
|
435
|
+
const l = Re || `{locationName} %({value},2)
|
|
436
|
+
{label}: %({value},2)`, r = t.properties.variables || {}, a = {
|
|
437
|
+
...t.properties,
|
|
438
|
+
value: t.properties.value,
|
|
439
|
+
measure: z(),
|
|
440
|
+
measureLabel: t.properties.measureLabel,
|
|
441
|
+
locationName: Ae(t, y, J),
|
|
442
|
+
label: Ae(t, y, J),
|
|
443
|
+
...r,
|
|
444
|
+
...we(m)
|
|
445
|
+
// expose applied filter params (e.g. {year}) to the tooltip
|
|
625
446
|
};
|
|
626
|
-
|
|
627
|
-
let
|
|
628
|
-
if (
|
|
629
|
-
const
|
|
630
|
-
`),
|
|
631
|
-
let
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
value:
|
|
635
|
-
label:
|
|
636
|
-
measure:
|
|
637
|
-
measureLabel:
|
|
638
|
-
...
|
|
447
|
+
w.current.attr("class", ut).style("position", "absolute").style("visibility", "hidden").style("visibility", "visible").html(() => {
|
|
448
|
+
let s = `<div style='font-size:${ft}px;' class='tooltip-content' >`;
|
|
449
|
+
if (t.properties.value != null) {
|
|
450
|
+
const d = l.split(`
|
|
451
|
+
`), f = d[0], T = d.length > 1 ? d[1] : null;
|
|
452
|
+
let S = 1, ee;
|
|
453
|
+
vt.length > 1 && H != "POINTS_MAP" ? (S = d.length > 2 ? 2 : 1, ee = d[S]) : ee = null, f && (s += k(f, a, F)), T && (s.endsWith("<hr>") || (s += "<hr>"), s += k(T, a, F)), ee && t.properties.children && t.properties.children.forEach((I) => {
|
|
454
|
+
const Le = {
|
|
455
|
+
value: I.value,
|
|
456
|
+
label: I.label,
|
|
457
|
+
measure: z(),
|
|
458
|
+
measureLabel: t.properties.measureLabel,
|
|
459
|
+
...r,
|
|
460
|
+
...I.variables,
|
|
461
|
+
...we(m)
|
|
639
462
|
};
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
)
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
})), a.filter(
|
|
648
|
-
(C) => C.location === s.properties[h]
|
|
649
|
-
).forEach((C) => {
|
|
650
|
-
L.endsWith("<hr>") || (L += "<hr>"), L += C.tooltip;
|
|
463
|
+
s.endsWith("<hr>") || (s += "<hr>"), s += k(ee, Le, F);
|
|
464
|
+
}), d.length > S + 1 && (s.endsWith("<hr>") || (s += "<hr>"), d.forEach((I, Le) => {
|
|
465
|
+
Le > S && (s.endsWith("<hr>") || (s += "<hr>"), s += k(I, a, F));
|
|
466
|
+
})), mt.filter(
|
|
467
|
+
(I) => I.location === t.properties[y]
|
|
468
|
+
).forEach((I) => {
|
|
469
|
+
s.endsWith("<hr>") || (s += "<hr>"), s += I.tooltip;
|
|
651
470
|
});
|
|
652
471
|
} else {
|
|
653
|
-
const
|
|
654
|
-
{label}: %({value},2)`,
|
|
472
|
+
const d = Re || `{locationName} %({value},2)
|
|
473
|
+
{label}: %({value},2)`, f = {
|
|
655
474
|
value: null,
|
|
656
|
-
measure:
|
|
657
|
-
measureLabel:
|
|
658
|
-
locationName:
|
|
659
|
-
...
|
|
475
|
+
measure: z(),
|
|
476
|
+
measureLabel: t.properties.measureLabel,
|
|
477
|
+
locationName: Ae(t, y, J),
|
|
478
|
+
...r
|
|
660
479
|
};
|
|
661
|
-
|
|
480
|
+
s += k(d, f, F), s += "</div>";
|
|
662
481
|
}
|
|
663
|
-
return
|
|
482
|
+
return s;
|
|
664
483
|
});
|
|
665
484
|
}
|
|
666
485
|
}
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
let
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
mousemove(e, s) {
|
|
673
|
-
this.positionTooltip(e);
|
|
674
|
-
}
|
|
675
|
-
mouseout(e, s) {
|
|
676
|
-
const { showTooltip: i } = this.props;
|
|
677
|
-
i && (g.select(this.getMapId()).select("svg").select("g").selectAll(".focus").attr("class", "active"), this.tooltip.style("visibility", "hidden"));
|
|
678
|
-
}
|
|
679
|
-
onClick(e, s) {
|
|
680
|
-
s.properties && (this.tooltip.style("visibility", "visible"), this.positionTooltip(e)), e.stopPropagation(), e.preventDefault();
|
|
486
|
+
function Ze(e) {
|
|
487
|
+
const o = w.current.node(), n = o ? o.offsetWidth : 0, i = window.scrollX + document.documentElement.clientWidth;
|
|
488
|
+
let l = e.pageX;
|
|
489
|
+
n && l + n > i && (l = e.pageX - n, l < window.scrollX && (l = window.scrollX)), w.current.style("top", e.pageY + "px").style("left", l + "px").style("margin-left", "8px");
|
|
681
490
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
const o = g.select(this.getMapId()).select("svg").select("g");
|
|
685
|
-
o.selectAll("circle").style("fill", this.props.defaultPointColor).style("stroke", "none"), o.select("#circle" + i).raise().style("fill", "#fff");
|
|
491
|
+
function Y(e) {
|
|
492
|
+
Ze(e);
|
|
686
493
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
this.state.selectedPolygon !== s.properties[i] && s.properties.value !== null && this.setState({ selectedPolygon: s.properties[i] });
|
|
494
|
+
function G() {
|
|
495
|
+
ie && (c.select(g()).select("svg").select("g").selectAll(".focus").attr("class", "active"), w.current.style("visibility", "hidden"));
|
|
690
496
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
g.select(this.getMapId()).select("svg").transition().call(this.zoom.scaleBy, 0.6667);
|
|
696
|
-
}
|
|
697
|
-
getSelectedMeasure() {
|
|
698
|
-
let e = this.state.selectedMeasure;
|
|
699
|
-
return !e && this.props.transformedData && this.props.transformedData.measures && this.props.transformedData.measures.length > 1 && (e = this.props.transformedData.measures[0]), e;
|
|
700
|
-
}
|
|
701
|
-
getCollectionField(e) {
|
|
702
|
-
const { topoJSONField: s } = this.props;
|
|
703
|
-
if (e && e.objects) {
|
|
704
|
-
const i = Object.keys(e.objects);
|
|
705
|
-
for (const o in i) {
|
|
706
|
-
const t = i[o];
|
|
707
|
-
if (e.objects[t].type == "GeometryCollection")
|
|
708
|
-
return t;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
return s;
|
|
712
|
-
}
|
|
713
|
-
extractFeatures(e) {
|
|
714
|
-
const s = this.getCollectionField(e);
|
|
715
|
-
return e && e.objects && e.objects[s] ? ie.feature(e, e.objects[s]).features : e && e.features ? e.features : [];
|
|
716
|
-
}
|
|
717
|
-
getLayers() {
|
|
718
|
-
const { layers: e } = this.state, { enabledLayers: s } = this.props;
|
|
719
|
-
return e && e.length > 0 ? e.map((o) => {
|
|
720
|
-
const t = s.find((a) => a.id == o.id);
|
|
721
|
-
return o.index = t ? t.index : 0, o;
|
|
722
|
-
}).sort((o, t) => parseInt(o.index) < parseInt(t.index) ? 1 : parseInt(o.index) > parseInt(t.index) ? -1 : 0) : [];
|
|
723
|
-
}
|
|
724
|
-
getFeatures() {
|
|
725
|
-
const e = this.getMainLayer(), s = this.getLayers();
|
|
726
|
-
if (e) {
|
|
727
|
-
const { transformedData: i, mappingField: o, app: t, mainLayerId: a, enabledLayers: n } = this.props;
|
|
728
|
-
let l = [];
|
|
729
|
-
try {
|
|
730
|
-
l = this.extractFeatures(e), l.map((p) => {
|
|
731
|
-
p.properties.layerId = a;
|
|
732
|
-
const d = s.find((u) => String(u.id) === String(a));
|
|
733
|
-
return d && (p.properties.layerMappingField = d.layerMappingField, p.properties.layerDatasource = d.layerDatasource, p.properties.layerApiField = d.layerApiField, p.properties.layerLocale = d.layerLocale, p.properties.displayLayerLabels = d.displayLayerLabels), n.forEach((u) => {
|
|
734
|
-
String(u.id) == a && Object.keys(u || {}).forEach((m) => {
|
|
735
|
-
p.properties[m] = u[m];
|
|
736
|
-
});
|
|
737
|
-
}), p;
|
|
738
|
-
}), s && s.forEach((p) => {
|
|
739
|
-
if (p.id != a) {
|
|
740
|
-
let d = this.extractFeatures(p.data);
|
|
741
|
-
d = d.map((u) => (u.properties.layerId = p.id, u.properties.layerMappingField = p.layerMappingField, u.properties.layerDatasource = p.layerDatasource, u.properties.layerApiField = p.layerApiField, u.properties.layerLocale = p.layerLocale, u.properties.displayLayerLabels = p.displayLayerLabels, u)), l = [...d, ...l];
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
} catch (p) {
|
|
745
|
-
console.log("error updating features .." + p);
|
|
746
|
-
}
|
|
747
|
-
const r = l.filter((p) => p.properties != null);
|
|
748
|
-
let h = i.locationsData;
|
|
749
|
-
return i.measures && i.measures.length > 1 && (h = i.locationsData.filter(
|
|
750
|
-
(p) => p.measure === this.getSelectedMeasure()
|
|
751
|
-
)), r.map((p) => {
|
|
752
|
-
if (h) {
|
|
753
|
-
const d = h.find((u) => {
|
|
754
|
-
const m = u.label ? ("" + u.label).toLowerCase() : "", v = p.properties[o] ? p.properties[o].toLowerCase() : "";
|
|
755
|
-
return m === v;
|
|
756
|
-
});
|
|
757
|
-
if (d) {
|
|
758
|
-
let u = d.measure;
|
|
759
|
-
i.measureLabelMap && d.measure && i.measureLabelMap[d.measure] && (u = i.measureLabelMap[d.measure]), p.properties.value = d.value, p.properties.measure = d.measure, p.properties.measureLabel = u, p.properties.children = d.children, p.properties.variables = d.variables, p.properties.hasDataRow = !0, Object.keys(d).forEach((m) => {
|
|
760
|
-
p.properties[m] = d[m];
|
|
761
|
-
});
|
|
762
|
-
} else
|
|
763
|
-
p.properties.value = null, p.properties.measure = null, p.properties.children = null, p.properties.measureLabel = null, p.properties.hasDataRow = !1;
|
|
764
|
-
}
|
|
765
|
-
}), r;
|
|
766
|
-
}
|
|
767
|
-
return [];
|
|
497
|
+
function $t(e, t, o) {
|
|
498
|
+
V(e, t), w.current.style("visibility", "visible"), Ze(e);
|
|
499
|
+
const n = c.select(g()).select("svg").select("g");
|
|
500
|
+
n.selectAll("circle").style("fill", Be).style("stroke", "none"), n.select("#circle" + o).raise().style("fill", "#fff");
|
|
768
501
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
return ".map.wrapper." + e;
|
|
502
|
+
function Ut(e, t) {
|
|
503
|
+
$ !== t.properties[y] && t.properties.value !== null && Nt(t.properties[y]);
|
|
772
504
|
}
|
|
773
|
-
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
return o[i] != t[i] && (a = !0), a;
|
|
505
|
+
function Vt(e) {
|
|
506
|
+
const t = e && e.appliedFilters || {}, o = m || {};
|
|
507
|
+
return t[P] != o[P];
|
|
777
508
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
(h) => h.properties != null && h.properties[t] == l
|
|
509
|
+
function Gt(e, t) {
|
|
510
|
+
let o = null;
|
|
511
|
+
if (wt && P) {
|
|
512
|
+
let n = $;
|
|
513
|
+
t && m && m[P] && (n = m[P]);
|
|
514
|
+
const i = e.filter(
|
|
515
|
+
(l) => l.properties != null && l.properties[y] == n
|
|
786
516
|
)[0];
|
|
787
|
-
|
|
517
|
+
i && i.properties != null && i.properties.value && (o = i);
|
|
788
518
|
}
|
|
789
|
-
return
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
let h = r.select("svg"), p = this.getWidth();
|
|
810
|
-
p === 0 ? p = window.innerWidth + Z[T()] : p += Z[T()];
|
|
811
|
-
const d = this.getHeight() - 100;
|
|
812
|
-
if (h.empty() ? h = r.append("svg") : h.selectAll("*").remove(), h.attr("style", `background-color:${o};`).attr("viewBox", `0 0 ${p} ${d}`).attr("preserveAspectRatio", "xMidYMid meet"), h.append("g").selectAll("path").data(e).enter().append("path").attr("fill", (m) => this.fillColor(m, l)).attr("d", g.geoPath().projection(this.projection)).attr("class", (m) => this.classColor(m)).on("mouseover", n !== "POINTS_MAP" ? this.showTooltip : null).on("mousemove", n !== "POINTS_MAP" ? this.mousemove : null).on("mouseout", n !== "POINTS_MAP" ? this.mouseout : null), this.mapPosition && h.transition().duration(300).call(
|
|
813
|
-
this.zoom.transform,
|
|
814
|
-
g.zoomIdentity.translate(this.mapPosition.x, this.mapPosition.y).scale(this.mapPosition.k)
|
|
815
|
-
), !this.mapPosition && t && t.x && t.y && t.k && (h.transition().duration(300).call(
|
|
816
|
-
this.zoom.transform,
|
|
817
|
-
g.zoomIdentity.translate(t.x, t.y).scale(t.k)
|
|
818
|
-
), n === "POINTS_MAP")) {
|
|
819
|
-
const v = {
|
|
519
|
+
return o;
|
|
520
|
+
}
|
|
521
|
+
function Jt() {
|
|
522
|
+
return yr(se);
|
|
523
|
+
}
|
|
524
|
+
function Xt(e, t) {
|
|
525
|
+
let o = se;
|
|
526
|
+
o || (o = ["mobile", "tablet"].includes(N()));
|
|
527
|
+
const n = Z(), i = c.select(g());
|
|
528
|
+
let l = i.select("svg"), r = ge();
|
|
529
|
+
r === 0 ? r = window.innerWidth + tt[N()] : r += tt[N()];
|
|
530
|
+
const a = he() - 100;
|
|
531
|
+
if (l.empty() ? l = i.append("svg") : l.selectAll("*").remove(), l.attr("style", `background-color:${bt};`).attr("viewBox", `0 0 ${r} ${a}`).attr("preserveAspectRatio", "xMidYMid meet"), l.append("g").selectAll("path").data(e).enter().append("path").attr("fill", (d) => ve(d, n)).attr("d", c.geoPath().projection(v.current)).attr("class", () => Jt()).on("mouseover", H !== "POINTS_MAP" ? V : null).on("mousemove", H !== "POINTS_MAP" ? Y : null).on("mouseout", H !== "POINTS_MAP" ? G : null), E.current && l.transition().duration(300).call(
|
|
532
|
+
A.current.transform,
|
|
533
|
+
c.zoomIdentity.translate(E.current.x, E.current.y).scale(E.current.k)
|
|
534
|
+
), !E.current && h && h.x && h.y && h.k && (l.transition().duration(300).call(
|
|
535
|
+
A.current.transform,
|
|
536
|
+
c.zoomIdentity.translate(h.x, h.y).scale(h.k)
|
|
537
|
+
), H === "POINTS_MAP")) {
|
|
538
|
+
const f = {
|
|
820
539
|
mobile: 100,
|
|
821
540
|
tablet: 0,
|
|
822
541
|
midTablet: 0,
|
|
823
542
|
desktop: 0,
|
|
824
543
|
laptop: 0,
|
|
825
544
|
wide: 0
|
|
826
|
-
}[
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
545
|
+
}[N()];
|
|
546
|
+
l.transition().duration(300).call(
|
|
547
|
+
A.current.transform,
|
|
548
|
+
c.zoomIdentity.translate(h.x + f, h.y).scale(h.k)
|
|
830
549
|
);
|
|
831
550
|
}
|
|
832
|
-
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
835
|
-
const
|
|
836
|
-
(
|
|
837
|
-
(
|
|
551
|
+
o || j ? l.call(A.current) : l.on("dblclick.zoom", null);
|
|
552
|
+
const s = Gt(e, t);
|
|
553
|
+
if (s) {
|
|
554
|
+
const d = U.current.bounds(s), f = [
|
|
555
|
+
(d[0][0] + d[1][0]) / 2,
|
|
556
|
+
(d[0][1] + d[1][1]) / 2
|
|
838
557
|
];
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
558
|
+
l.transition().duration(750).call(
|
|
559
|
+
A.current.transform,
|
|
560
|
+
c.zoomIdentity.translate(r / 2, a / 2).scale(12).translate(-f[0], -f[1])
|
|
842
561
|
);
|
|
843
562
|
}
|
|
844
563
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
return e.nationalData.value;
|
|
848
|
-
}
|
|
849
|
-
selectedMeasureChanged(e) {
|
|
850
|
-
this.state.selectedMeasure != e && this.setState({ selectedMeasure: e });
|
|
564
|
+
function Zt() {
|
|
565
|
+
return u.nationalData.value;
|
|
851
566
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
return e && Object.keys(e).forEach((o) => {
|
|
855
|
-
const t = e[o];
|
|
856
|
-
t && (s[o] = Array.isArray(t) ? t.join(" ,") : t);
|
|
857
|
-
}), s;
|
|
567
|
+
function Yt(e) {
|
|
568
|
+
R != e && kt(e);
|
|
858
569
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
)), i.find(
|
|
865
|
-
(t) => t.label === e
|
|
866
|
-
);
|
|
570
|
+
function qt() {
|
|
571
|
+
let e = u.locationsData;
|
|
572
|
+
return u.measures && u.measures.length > 1 && (e = u.locationsData.filter(
|
|
573
|
+
(t) => t.measure === z()
|
|
574
|
+
)), e.find((t) => t.label === C);
|
|
867
575
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
if (!e)
|
|
576
|
+
function Kt() {
|
|
577
|
+
if (!C)
|
|
871
578
|
return null;
|
|
872
|
-
const t =
|
|
873
|
-
(
|
|
579
|
+
const t = X().find(
|
|
580
|
+
(o) => o.properties[x] === C
|
|
874
581
|
);
|
|
875
582
|
if (t && t.properties.displayLayerLabels && t.properties.layerLocale) {
|
|
876
|
-
const
|
|
877
|
-
return
|
|
583
|
+
const o = t.properties.layerMappingField || x, n = t.properties[o];
|
|
584
|
+
return fr(
|
|
585
|
+
J,
|
|
586
|
+
n,
|
|
587
|
+
t.properties.layerLocale
|
|
588
|
+
);
|
|
878
589
|
}
|
|
879
|
-
return
|
|
590
|
+
return C;
|
|
880
591
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
if (o != null) {
|
|
884
|
-
const t = s.find((a) => {
|
|
885
|
-
if (a.min != null && a.max != null)
|
|
886
|
-
return o >= a.min && o <= a.max;
|
|
887
|
-
if (a.min != null)
|
|
888
|
-
return o >= a.min;
|
|
889
|
-
if (a.max != null)
|
|
890
|
-
return o <= a.max;
|
|
891
|
-
});
|
|
892
|
-
return t && t.color ? t.color : i;
|
|
893
|
-
}
|
|
894
|
-
return i;
|
|
592
|
+
function Qt(e) {
|
|
593
|
+
return mr(e, Z(), We);
|
|
895
594
|
}
|
|
896
|
-
|
|
897
|
-
return /* @__PURE__ */
|
|
898
|
-
Q,
|
|
899
|
-
{
|
|
900
|
-
basic: !0,
|
|
901
|
-
padded: !0,
|
|
902
|
-
textAlign: "center",
|
|
903
|
-
style: { margin: "30px" },
|
|
904
|
-
children: /* @__PURE__ */ b(ee, { active: !0, inverted: !0, children: /* @__PURE__ */ b(te, { size: "medium" }) })
|
|
905
|
-
}
|
|
906
|
-
) });
|
|
595
|
+
function er() {
|
|
596
|
+
return /* @__PURE__ */ p(Qe, { className: "loading", children: /* @__PURE__ */ p(sr, { basic: !0, padded: !0, textAlign: "center", style: { margin: "30px" }, children: /* @__PURE__ */ p(ir, { active: !0, inverted: !0, children: /* @__PURE__ */ p(cr, { size: "medium" }) }) }) });
|
|
907
597
|
}
|
|
908
|
-
|
|
909
|
-
return /* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
911
|
-
/* @__PURE__ */
|
|
912
|
-
/* @__PURE__ */
|
|
598
|
+
function tr() {
|
|
599
|
+
return /* @__PURE__ */ b(xe, { icon: !0, warning: !0, children: [
|
|
600
|
+
/* @__PURE__ */ p(te, { name: "map outline" }),
|
|
601
|
+
/* @__PURE__ */ b(xe.Content, { children: [
|
|
602
|
+
/* @__PURE__ */ p(xe.Header, { children: "No map selected" }),
|
|
913
603
|
"Pick one from the list in the ",
|
|
914
|
-
/* @__PURE__ */
|
|
604
|
+
/* @__PURE__ */ p("strong", { children: "Map Layers" }),
|
|
915
605
|
" section."
|
|
916
606
|
] })
|
|
917
607
|
] });
|
|
918
608
|
}
|
|
919
|
-
|
|
920
|
-
let
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
showOverallValue: r,
|
|
930
|
-
unique: h,
|
|
931
|
-
highlightedLocation: p,
|
|
932
|
-
labelFontColor: d,
|
|
933
|
-
legendFontSize: u,
|
|
934
|
-
editing: m,
|
|
935
|
-
highlightedLocLabelFormat: v,
|
|
936
|
-
noDataText: c
|
|
937
|
-
} = this.props;
|
|
938
|
-
t || (t = !!["mobile", "tablet", "midTablet"].includes(
|
|
939
|
-
T()
|
|
940
|
-
));
|
|
941
|
-
const f = this.getAvg(), y = this.getFilters(), I = this.getHighlightedLocationData(), A = {
|
|
942
|
-
backgroundColor: this.getHighlightedLocationColor(I),
|
|
943
|
-
color: d,
|
|
944
|
-
fontSize: u + "px"
|
|
609
|
+
M.current.zoomed = Dt, M.current.zoomEnd = Pt, M.current.getFeatures = X, M.current.updateFeatures = Xe, M.current.getMapId = g, fe.current || (fe.current = () => {
|
|
610
|
+
let e = null;
|
|
611
|
+
clearTimeout(e), e = setTimeout(() => {
|
|
612
|
+
c.select(M.current.getMapId()).selectAll(".map-labels-container").size() > 0 || M.current.updateFeatures(M.current.getFeatures(), !1);
|
|
613
|
+
}, 300);
|
|
614
|
+
}), et(() => {
|
|
615
|
+
const e = fe.current;
|
|
616
|
+
return window.addEventListener("scroll", e, { passive: !0 }), window.addEventListener("touchmove", e, { passive: !0 }), Ge(), w.current = c.select("body").append("div").style("position", "absolute").style("visibility", "hidden").style("pointer-events", "none"), () => {
|
|
617
|
+
var t;
|
|
618
|
+
window.removeEventListener("scroll", e), window.removeEventListener("touchmove", e), (t = w.current) == null || t.remove();
|
|
945
619
|
};
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
620
|
+
}, []), et(() => {
|
|
621
|
+
if (!$e.current) {
|
|
622
|
+
$e.current = !0, de.current = O, me.current = { selectedMeasure: R, layers: B, selectedPolygon: $ };
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const e = de.current, t = me.current;
|
|
626
|
+
if (P) {
|
|
627
|
+
const i = [], l = [], r = e.appliedFilters;
|
|
628
|
+
r && Object.keys(r).forEach((a) => {
|
|
629
|
+
r[a] != null && r[a] instanceof Array && i.push(
|
|
630
|
+
...r[a].filter((s) => s != Number.MIN_SAFE_INTEGER)
|
|
631
|
+
);
|
|
632
|
+
}), m && Object.keys(m).forEach((a) => {
|
|
633
|
+
m[a] != null && m[a] instanceof Array && l.push(
|
|
634
|
+
...m[a].filter((s) => s != Number.MIN_SAFE_INTEGER)
|
|
635
|
+
);
|
|
636
|
+
}), i.length > 0 && l.length == 0 && Je();
|
|
637
|
+
}
|
|
638
|
+
w.current.style("visibility", "hidden"), e.enabledLayers.length != D.length && Ge();
|
|
639
|
+
const o = X();
|
|
640
|
+
e.center !== le && (E.current = null, v.current.scale(ke).center(le).translate([ge() / 2, he() / 2]));
|
|
641
|
+
const n = Vt(e);
|
|
642
|
+
Xt(o, n), B && u && (u != e.transformedData || B != t.layers || R != t.selectedMeasure || $ != t.selectedPolygon || e.mainLayerId !== W || JSON.stringify(e.enabledLayers) != JSON.stringify(D)) && Xe(X(), n), de.current = O, me.current = { selectedMeasure: R, layers: B, selectedPolygon: $ };
|
|
643
|
+
});
|
|
644
|
+
let be = se;
|
|
645
|
+
be || (be = !!["mobile", "tablet", "midTablet"].includes(
|
|
646
|
+
N()
|
|
647
|
+
));
|
|
648
|
+
const rr = Zt(), lr = we(m), q = qt(), Ye = {
|
|
649
|
+
backgroundColor: Qt(q),
|
|
650
|
+
color: Oe,
|
|
651
|
+
fontSize: dt + "px"
|
|
652
|
+
};
|
|
653
|
+
j && (Ye.marginTop = "25px");
|
|
654
|
+
const qe = () => /* @__PURE__ */ b(Qe, { fluid: !0, className: "footnote ", children: [
|
|
655
|
+
/* @__PURE__ */ b(Fe, { columns: 2, children: [
|
|
656
|
+
O.app !== "csv" && ze && /* @__PURE__ */ p(Fe.Column, { textAlign: "left", width: 4, children: /* @__PURE__ */ b("div", { className: "national-average-div", children: [
|
|
657
|
+
/* @__PURE__ */ p("span", { className: "national-avg-label", children: Tt }),
|
|
658
|
+
/* @__PURE__ */ p("span", { className: "national-avg-value", children: k(Ce, { value: rr }, F) })
|
|
659
|
+
] }) }),
|
|
660
|
+
/* @__PURE__ */ p(
|
|
661
|
+
Fe.Column,
|
|
662
|
+
{
|
|
663
|
+
textAlign: "right",
|
|
664
|
+
width: O.app !== "csv" && ze ? 12 : 16,
|
|
665
|
+
children: /* @__PURE__ */ p(
|
|
666
|
+
ur,
|
|
983
667
|
{
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
668
|
+
filteredBreaks: Z(),
|
|
669
|
+
formattedLegendTitle: k(Mt, { ...lr }, F),
|
|
670
|
+
selectedMeasure: R,
|
|
671
|
+
...O
|
|
987
672
|
}
|
|
988
|
-
)
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
/* @__PURE__ */ M(
|
|
998
|
-
"div",
|
|
673
|
+
)
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
] }),
|
|
677
|
+
/* @__PURE__ */ p("div", { className: "measure-selector", children: /* @__PURE__ */ b("ul", { children: [
|
|
678
|
+
Ie && /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("span", { className: "label", children: Ie }) }),
|
|
679
|
+
u && u.measures && u.measures.length > 1 && u.measures.map((e) => /* @__PURE__ */ b("li", { onClick: () => Yt(e), children: [
|
|
680
|
+
/* @__PURE__ */ p(
|
|
681
|
+
"input",
|
|
999
682
|
{
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
children: [
|
|
1005
|
-
I ? /* @__PURE__ */ b(
|
|
1006
|
-
"div",
|
|
1007
|
-
{
|
|
1008
|
-
className: "highlighted-loc-info",
|
|
1009
|
-
style: A,
|
|
1010
|
-
children: /* @__PURE__ */ M("span", { children: [
|
|
1011
|
-
" ",
|
|
1012
|
-
k(
|
|
1013
|
-
v,
|
|
1014
|
-
{
|
|
1015
|
-
value: I.value,
|
|
1016
|
-
locationName: this.getTranslatedHighlightedLocationName() || I.label,
|
|
1017
|
-
measureName: I.measure
|
|
1018
|
-
},
|
|
1019
|
-
o
|
|
1020
|
-
)
|
|
1021
|
-
] })
|
|
1022
|
-
}
|
|
1023
|
-
) : /* @__PURE__ */ b(R, { children: " " }),
|
|
1024
|
-
(m || t) && !de && /* @__PURE__ */ M("div", { className: "control panel ignore", children: [
|
|
1025
|
-
/* @__PURE__ */ b("div", { className: "zoom plus", onClick: this.onZoomIn, children: /* @__PURE__ */ b(E, { name: "plus", size: "large" }) }),
|
|
1026
|
-
/* @__PURE__ */ b("div", { className: "zoom minus", onClick: this.onZoomOut, children: /* @__PURE__ */ b(E, { name: "minus", size: "large" }) }),
|
|
1027
|
-
/* @__PURE__ */ b(
|
|
1028
|
-
se,
|
|
1029
|
-
{
|
|
1030
|
-
content: /* @__PURE__ */ b(
|
|
1031
|
-
K,
|
|
1032
|
-
{
|
|
1033
|
-
id: "map.reset.tooltip",
|
|
1034
|
-
defaultMessage: "Reset zoom"
|
|
1035
|
-
}
|
|
1036
|
-
),
|
|
1037
|
-
trigger: /* @__PURE__ */ b("div", { className: "reset", onClick: this.onReset, children: /* @__PURE__ */ b(E, { name: "repeat", size: "large" }) })
|
|
1038
|
-
}
|
|
1039
|
-
)
|
|
1040
|
-
] })
|
|
1041
|
-
]
|
|
683
|
+
checked: z() === e,
|
|
684
|
+
type: "radio",
|
|
685
|
+
value: e,
|
|
686
|
+
readOnly: !0
|
|
1042
687
|
}
|
|
1043
688
|
),
|
|
1044
|
-
|
|
1045
|
-
] })
|
|
1046
|
-
] })
|
|
1047
|
-
}
|
|
689
|
+
/* @__PURE__ */ p("label", { children: u.measureLabelMap[e] || e })
|
|
690
|
+
] }, e))
|
|
691
|
+
] }) })
|
|
692
|
+
] });
|
|
693
|
+
return /* @__PURE__ */ b("div", { className: "map component wp-data-viz-map", ref: pe, children: [
|
|
694
|
+
je && (j ? tr() : er()),
|
|
695
|
+
!je && /* @__PURE__ */ b(Ke, { children: [
|
|
696
|
+
!at && /* @__PURE__ */ p(qe, {}),
|
|
697
|
+
/* @__PURE__ */ b(
|
|
698
|
+
"div",
|
|
699
|
+
{
|
|
700
|
+
className: "map wrapper scaling-svg-container " + Me,
|
|
701
|
+
style: { height: Ne - dr[N()] + "px" },
|
|
702
|
+
children: [
|
|
703
|
+
q ? /* @__PURE__ */ p("div", { className: "highlighted-loc-info", style: Ye, children: /* @__PURE__ */ b("span", { children: [
|
|
704
|
+
" ",
|
|
705
|
+
k(
|
|
706
|
+
Ft,
|
|
707
|
+
{
|
|
708
|
+
value: q.value,
|
|
709
|
+
locationName: Kt() || q.label,
|
|
710
|
+
measureName: q.measure
|
|
711
|
+
},
|
|
712
|
+
F
|
|
713
|
+
)
|
|
714
|
+
] }) }) : /* @__PURE__ */ p(Ke, { children: " " }),
|
|
715
|
+
(j || be) && !wr && /* @__PURE__ */ b("div", { className: "control panel ignore", children: [
|
|
716
|
+
/* @__PURE__ */ p("div", { className: "zoom plus", onClick: Ot, children: /* @__PURE__ */ p(te, { name: "plus", size: "large" }) }),
|
|
717
|
+
/* @__PURE__ */ p("div", { className: "zoom minus", onClick: Wt, children: /* @__PURE__ */ p(te, { name: "minus", size: "large" }) }),
|
|
718
|
+
/* @__PURE__ */ p(
|
|
719
|
+
or,
|
|
720
|
+
{
|
|
721
|
+
content: /* @__PURE__ */ p(ar, { id: "map.reset.tooltip", defaultMessage: "Reset zoom" }),
|
|
722
|
+
trigger: /* @__PURE__ */ p("div", { className: "reset", onClick: Je, children: /* @__PURE__ */ p(te, { name: "repeat", size: "large" }) })
|
|
723
|
+
}
|
|
724
|
+
)
|
|
725
|
+
] })
|
|
726
|
+
]
|
|
727
|
+
}
|
|
728
|
+
),
|
|
729
|
+
at && /* @__PURE__ */ p(qe, {})
|
|
730
|
+
] })
|
|
731
|
+
] });
|
|
1048
732
|
}
|
|
1049
|
-
const
|
|
733
|
+
const Sr = nr(Ar);
|
|
1050
734
|
export {
|
|
1051
|
-
|
|
1052
|
-
|
|
735
|
+
Sr as default,
|
|
736
|
+
fr as getTranslatedItemLabel
|
|
1053
737
|
};
|