@macrostrat/map-interface 1.4.0 → 1.4.2
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/CHANGELOG.md +12 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/{map-interface.7295b0a2.js → map-interface.7aaa58c9.js} +2 -2
- package/dist/node/map-interface.7aaa58c9.js.map +1 -0
- package/dist/node/{map-interface.f3e12e03.js → map-interface.7e13bea8.js} +2 -2
- package/dist/node/{map-interface.f3e12e03.js.map → map-interface.7e13bea8.js.map} +1 -1
- package/dist/node/{map-interface.0dc4417b.js → map-interface.ce86a010.js} +2 -2
- package/dist/node/{map-interface.0dc4417b.js.map → map-interface.ce86a010.js.map} +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/map-panel/components/buttons.module.styl +5 -0
- package/src/map-panel/components/buttons.ts +56 -0
- package/src/map-panel/components/card.module.styl +43 -0
- package/src/map-panel/components/closeable-card.ts +64 -0
- package/src/map-panel/components/docs.module.styl +93 -0
- package/src/map-panel/components/docs.ts +92 -0
- package/src/map-panel/components/info-blocks.module.styl +39 -0
- package/src/map-panel/components/info-blocks.ts +88 -0
- package/src/map-panel/components/info-drawer/fossil-collections/collections.tsx +156 -0
- package/src/map-panel/components/info-drawer/fossil-collections/index.ts +21 -0
- package/src/map-panel/components/info-drawer/fossil-collections/main.module.sass +16 -0
- package/src/map-panel/components/info-drawer/index.ts +117 -0
- package/src/map-panel/components/info-drawer/macrostrat-linked.ts +399 -0
- package/src/map-panel/components/info-drawer/main.module.styl +67 -0
- package/src/map-panel/components/info-drawer/physiography.ts +29 -0
- package/src/map-panel/components/info-drawer/reg-strat.ts +74 -0
- package/src/map-panel/components/info-drawer/xdd-panel/Article.tsx +69 -0
- package/src/map-panel/components/info-drawer/xdd-panel/Journal.tsx +48 -0
- package/src/map-panel/components/info-drawer/xdd-panel/index.ts +69 -0
- package/src/map-panel/components/transitions/index.ts +24 -0
- package/src/map-panel/components/transitions/main.module.styl +55 -0
- package/src/map-panel/index.ts +1 -0
- package/src/map-panel/utils/formatting.ts +14 -0
- package/src/map-panel/utils/fossils.ts +209 -0
- package/src/map-panel/utils/index.ts +157 -0
- package/dist/node/map-interface.7295b0a2.js.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Spinner } from "@blueprintjs/core";
|
|
2
|
+
import h from "@macrostrat/hyper";
|
|
3
|
+
import Journal from "./Journal";
|
|
4
|
+
import { ExpansionPanel } from "@macrostrat/map-interface";
|
|
5
|
+
|
|
6
|
+
export interface XDDSnippet {
|
|
7
|
+
pubname: string;
|
|
8
|
+
publisher: string;
|
|
9
|
+
_gddid: string;
|
|
10
|
+
title: string;
|
|
11
|
+
doi: string;
|
|
12
|
+
coverDate: string;
|
|
13
|
+
URL: string;
|
|
14
|
+
authors: string;
|
|
15
|
+
hits: number;
|
|
16
|
+
highlight: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function XddExpansion({ xddInfo }) {
|
|
20
|
+
return h(xDDPanelCore, {
|
|
21
|
+
className: "regional-panel",
|
|
22
|
+
data: xddInfo,
|
|
23
|
+
isFetching: xddInfo == undefined || xddInfo.length === 0,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function xDDPanelCore({ isFetching, data: xddInfo, ...rest }) {
|
|
28
|
+
const groupedData = groupSnippetsByJournal(xddInfo);
|
|
29
|
+
|
|
30
|
+
return h(
|
|
31
|
+
ExpansionPanel,
|
|
32
|
+
{
|
|
33
|
+
className: "regional-panel",
|
|
34
|
+
title: "Primary literature",
|
|
35
|
+
helpText: "via xDD",
|
|
36
|
+
...rest,
|
|
37
|
+
},
|
|
38
|
+
[
|
|
39
|
+
h.if(isFetching)(Spinner),
|
|
40
|
+
h.if(!isFetching && xddInfo.length > 0)([
|
|
41
|
+
Array.from(groupedData.entries())?.map(([journal, snippets]) => {
|
|
42
|
+
return h(Journal, {
|
|
43
|
+
name: journal,
|
|
44
|
+
articles: snippets,
|
|
45
|
+
publisher: snippets[0].publisher,
|
|
46
|
+
key: journal,
|
|
47
|
+
});
|
|
48
|
+
}),
|
|
49
|
+
]),
|
|
50
|
+
],
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function groupSnippetsByJournal(
|
|
55
|
+
snippets: XDDSnippet[],
|
|
56
|
+
): Map<string, XDDSnippet[]> {
|
|
57
|
+
const journals = new Map<string, XDDSnippet[]>();
|
|
58
|
+
if (!snippets || snippets.length === 0) {
|
|
59
|
+
return journals;
|
|
60
|
+
}
|
|
61
|
+
for (let snippet of snippets) {
|
|
62
|
+
const { pubname: journal } = snippet;
|
|
63
|
+
if (!journals.has(journal)) {
|
|
64
|
+
journals.set(journal, []);
|
|
65
|
+
}
|
|
66
|
+
journals.get(journal).push(snippet);
|
|
67
|
+
}
|
|
68
|
+
return journals;
|
|
69
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import hyper from "@macrostrat/hyper";
|
|
2
|
+
import styles from "./main.module.styl";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { Spinner } from "@blueprintjs/core";
|
|
5
|
+
import { useTransition } from "transition-hook";
|
|
6
|
+
|
|
7
|
+
const h = hyper.styled(styles);
|
|
8
|
+
|
|
9
|
+
function LoadingArea(props) {
|
|
10
|
+
const { loaded, children = null, className } = props;
|
|
11
|
+
const trans = useTransition(loaded, 500);
|
|
12
|
+
const invTrans = useTransition(!loaded, 500);
|
|
13
|
+
|
|
14
|
+
return h(
|
|
15
|
+
"div.loading-area",
|
|
16
|
+
{ className: classNames(className, trans.stage) },
|
|
17
|
+
[
|
|
18
|
+
h.if(invTrans.shouldMount)("div.spinner", null, h(Spinner)),
|
|
19
|
+
h.if(trans.shouldMount)("div.data", null, children),
|
|
20
|
+
],
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { LoadingArea };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
transitionable()
|
|
2
|
+
&:global(.enter)
|
|
3
|
+
opacity: 0
|
|
4
|
+
&:global(.enter-active)
|
|
5
|
+
opacity: 1
|
|
6
|
+
transition: opacity 0.5s ease-in-out, height 0.5s ease-in-out, max-height 0.5s ease-in-out
|
|
7
|
+
&:global(.exit)
|
|
8
|
+
opacity: 1
|
|
9
|
+
&:global(.exit-active)
|
|
10
|
+
opacity: 0
|
|
11
|
+
transition: opacity 0.5s ease-in-out, height 0.5s ease-in-out, max-height 0.5s ease-in-out
|
|
12
|
+
transition: height 0.5s ease-in-out, max-height 0.5s ease-in-out
|
|
13
|
+
|
|
14
|
+
.transition-item
|
|
15
|
+
transitionable()
|
|
16
|
+
|
|
17
|
+
.loading-area
|
|
18
|
+
.spinner, .data
|
|
19
|
+
transition: height 0.5s ease-in, opacity 0.2s ease-in
|
|
20
|
+
|
|
21
|
+
.spinner
|
|
22
|
+
position absolute
|
|
23
|
+
top 0
|
|
24
|
+
left 0
|
|
25
|
+
width: 100%
|
|
26
|
+
height 100%
|
|
27
|
+
min-height: 90px
|
|
28
|
+
background-color: var(--panel-background-color)
|
|
29
|
+
padding: 15px
|
|
30
|
+
|
|
31
|
+
&.enter
|
|
32
|
+
.spinner
|
|
33
|
+
height: 0
|
|
34
|
+
opacity: 0
|
|
35
|
+
|
|
36
|
+
.data
|
|
37
|
+
opacity: 1
|
|
38
|
+
|
|
39
|
+
&.from
|
|
40
|
+
.spinner
|
|
41
|
+
height: 90px
|
|
42
|
+
opacity: 1
|
|
43
|
+
|
|
44
|
+
.data
|
|
45
|
+
opacity: 0
|
|
46
|
+
|
|
47
|
+
&.leave
|
|
48
|
+
.spinner
|
|
49
|
+
height: 90px
|
|
50
|
+
opacity: 1
|
|
51
|
+
|
|
52
|
+
.data
|
|
53
|
+
opacity: 0
|
|
54
|
+
|
|
55
|
+
//.transition-item.infodrawer-info
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./components/info-drawer";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { format } from "d3-format";
|
|
2
|
+
|
|
3
|
+
export const fmt4 = format(".4~f");
|
|
4
|
+
export const fmt3 = format(".3~f");
|
|
5
|
+
export const fmt2 = format(".2~f");
|
|
6
|
+
export const fmt1 = format(".1~f");
|
|
7
|
+
export const fmtInt = format(".0f");
|
|
8
|
+
|
|
9
|
+
export const addCommas = (x) => {
|
|
10
|
+
x = parseInt(x);
|
|
11
|
+
var parts = x.toString().split(".");
|
|
12
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
13
|
+
return parts.join(".");
|
|
14
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export function makeOccurrenceTree(data) {
|
|
2
|
+
let occurrenceTree = { phyla: [] };
|
|
3
|
+
let rankMap = {
|
|
4
|
+
25: "unranked",
|
|
5
|
+
23: "kingdom",
|
|
6
|
+
22: "subkingdom",
|
|
7
|
+
21: "superphylum",
|
|
8
|
+
20: "phylum",
|
|
9
|
+
19: "subphylum",
|
|
10
|
+
18: "superclass",
|
|
11
|
+
17: "class",
|
|
12
|
+
16: "subclass",
|
|
13
|
+
15: "infraclass",
|
|
14
|
+
14: "superorder",
|
|
15
|
+
13: "order",
|
|
16
|
+
12: "suborder",
|
|
17
|
+
11: "infraorder",
|
|
18
|
+
10: "superfamily",
|
|
19
|
+
9: "family",
|
|
20
|
+
8: "subfamily",
|
|
21
|
+
7: "tribe",
|
|
22
|
+
6: "subtribe",
|
|
23
|
+
5: "genus",
|
|
24
|
+
4: "subgenus",
|
|
25
|
+
3: "species",
|
|
26
|
+
2: "subspecies",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function getIndex(data, term, property) {
|
|
30
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
31
|
+
if (data[i][property] === term) return i;
|
|
32
|
+
}
|
|
33
|
+
return -1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
data.forEach((d) => {
|
|
37
|
+
// Some preprocessing
|
|
38
|
+
d.rank = d.rnk ? rankMap[d.rnk] : d.idr ? rankMap[d.idr] : "Unknown";
|
|
39
|
+
d.italics = d.rnk < 6 ? "italics" : "";
|
|
40
|
+
if (typeof d.tna === "undefined") {
|
|
41
|
+
d.tna = d.idn;
|
|
42
|
+
}
|
|
43
|
+
d.old_name = d.tna.split(" ")[0] != d.idg ? d.tna : "";
|
|
44
|
+
d.url =
|
|
45
|
+
d.rank === "species"
|
|
46
|
+
? d.idg + " " + d.ids
|
|
47
|
+
: d.tid
|
|
48
|
+
? d.tid.split(":")[1] > 0
|
|
49
|
+
? d.idg
|
|
50
|
+
: ""
|
|
51
|
+
: "";
|
|
52
|
+
|
|
53
|
+
// If it has a genus name...
|
|
54
|
+
if (d.idg) {
|
|
55
|
+
let genusRes = d.rsg ? d.rsg + " " : "";
|
|
56
|
+
let speciesRes = d.rss ? " " + d.rss + " " : " ";
|
|
57
|
+
d.genusRes = genusRes;
|
|
58
|
+
// If it's a species...
|
|
59
|
+
if (d.rank === "species") {
|
|
60
|
+
d.display_name1 = d.tna;
|
|
61
|
+
d.display_name2 = d.tna != d.idg + " " + d.ids ? "(" + d.tna + ")" : "";
|
|
62
|
+
d.display_name3 = "";
|
|
63
|
+
} else {
|
|
64
|
+
d.display_name1 = d.idg;
|
|
65
|
+
d.display_name2 = speciesRes;
|
|
66
|
+
d.display_name3 = d.ids;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
d.display_name1 = d.tna;
|
|
70
|
+
d.display_name2 = "";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Find unique phyla
|
|
74
|
+
let phyla = [];
|
|
75
|
+
for (let i = 0; i < occurrenceTree.phyla.length; i++) {
|
|
76
|
+
phyla.push(occurrenceTree.phyla[i].phylum);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (phyla.indexOf(d.phl) < 0) {
|
|
80
|
+
let newPhylum = { phylum: d.phl, classes: [] };
|
|
81
|
+
occurrenceTree.phyla.push(newPhylum);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Find unique phylum/class combinations
|
|
85
|
+
let phyla_classes = [];
|
|
86
|
+
for (let i = 0; i < occurrenceTree.phyla.length; i++) {
|
|
87
|
+
for (let j = 0; j < occurrenceTree.phyla[i].classes.length; j++) {
|
|
88
|
+
phyla_classes.push(
|
|
89
|
+
occurrenceTree.phyla[i].phylum +
|
|
90
|
+
"-" +
|
|
91
|
+
occurrenceTree.phyla[i].classes[j].nameClass,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (phyla_classes.indexOf(d.phl + "-" + d.cll) < 0) {
|
|
97
|
+
let newClass = { nameClass: d.cll, families: [] };
|
|
98
|
+
let phylumIndex = getIndex(occurrenceTree.phyla, d.phl, "phylum");
|
|
99
|
+
occurrenceTree.phyla[phylumIndex]["classes"].push(newClass);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Find unique phylum/class/family combinations
|
|
103
|
+
let phyla_class_family = [];
|
|
104
|
+
for (let i = 0; i < occurrenceTree.phyla.length; i++) {
|
|
105
|
+
for (let j = 0; j < occurrenceTree.phyla[i].classes.length; j++) {
|
|
106
|
+
for (
|
|
107
|
+
let k = 0;
|
|
108
|
+
k < occurrenceTree.phyla[i].classes[j].families.length;
|
|
109
|
+
k++
|
|
110
|
+
) {
|
|
111
|
+
phyla_class_family.push(
|
|
112
|
+
occurrenceTree.phyla[i].phylum +
|
|
113
|
+
"-" +
|
|
114
|
+
occurrenceTree.phyla[i].classes[j].nameClass +
|
|
115
|
+
"-" +
|
|
116
|
+
occurrenceTree.phyla[i].classes[j].families[k].family,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (phyla_class_family.indexOf(d.phl + "-" + d.cll + "-" + d.fml) < 0) {
|
|
123
|
+
let newFamily = { family: d.fml, genera: [] };
|
|
124
|
+
let phylumIndex = getIndex(occurrenceTree.phyla, d.phl, "phylum");
|
|
125
|
+
let classIndex = getIndex(
|
|
126
|
+
occurrenceTree.phyla[phylumIndex].classes,
|
|
127
|
+
d.cll,
|
|
128
|
+
"nameClass",
|
|
129
|
+
);
|
|
130
|
+
occurrenceTree.phyla[phylumIndex].classes[classIndex]["families"].push(
|
|
131
|
+
newFamily,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Place genera into the right phylum/class/family
|
|
136
|
+
let phylumIndex = getIndex(occurrenceTree.phyla, d.phl, "phylum");
|
|
137
|
+
let classIndex = getIndex(
|
|
138
|
+
occurrenceTree.phyla[phylumIndex].classes,
|
|
139
|
+
d.cll,
|
|
140
|
+
"nameClass",
|
|
141
|
+
);
|
|
142
|
+
let familyIndex = getIndex(
|
|
143
|
+
occurrenceTree.phyla[phylumIndex].classes[classIndex].families,
|
|
144
|
+
d.fml,
|
|
145
|
+
"family",
|
|
146
|
+
);
|
|
147
|
+
occurrenceTree.phyla[phylumIndex].classes[classIndex].families[
|
|
148
|
+
familyIndex
|
|
149
|
+
].genera.push(d);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
for (let i = 0; i < occurrenceTree.phyla.length; i++) {
|
|
153
|
+
let undefinedClassIndex;
|
|
154
|
+
for (let j = 0; j < occurrenceTree.phyla[i].classes.length; j++) {
|
|
155
|
+
let undefinedFamilyIndex;
|
|
156
|
+
for (
|
|
157
|
+
let k = 0;
|
|
158
|
+
k < occurrenceTree.phyla[i].classes[j].families.length;
|
|
159
|
+
k++
|
|
160
|
+
) {
|
|
161
|
+
if (
|
|
162
|
+
typeof occurrenceTree.phyla[i].classes[j].families[k].family ===
|
|
163
|
+
"undefined"
|
|
164
|
+
) {
|
|
165
|
+
undefinedFamilyIndex = k;
|
|
166
|
+
occurrenceTree.phyla[i].classes[j].families[k].family =
|
|
167
|
+
"Miscellaneous " +
|
|
168
|
+
(typeof occurrenceTree.phyla[i].classes[j].nameClass ===
|
|
169
|
+
"undefined")
|
|
170
|
+
? "Miscellaneous unranked taxa"
|
|
171
|
+
: occurrenceTree.phyla[i].classes[j].nameClass;
|
|
172
|
+
occurrenceTree.phyla[i].classes[j].families[k].noFamily = true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (typeof undefinedFamilyIndex != "undefined") {
|
|
177
|
+
occurrenceTree.phyla[i].classes[j].families.push(
|
|
178
|
+
occurrenceTree.phyla[i].classes[j].families.splice(
|
|
179
|
+
undefinedFamilyIndex,
|
|
180
|
+
1,
|
|
181
|
+
)[0],
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (typeof occurrenceTree.phyla[i].classes[j].nameClass === "undefined") {
|
|
186
|
+
undefinedFamilyIndex = j;
|
|
187
|
+
occurrenceTree.phyla[i].classes[j].nameClass =
|
|
188
|
+
"Miscellaneous " +
|
|
189
|
+
(typeof occurrenceTree.phyla[i].phylum === "undefined")
|
|
190
|
+
? "Miscellaneous unranked taxa"
|
|
191
|
+
: occurrenceTree.phyla[i].phylum;
|
|
192
|
+
occurrenceTree.phyla[i].classes[j].noClass = true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (typeof undefinedClassIndex != "undefined") {
|
|
197
|
+
occurrenceTree.phyla[i].classes.push(
|
|
198
|
+
occurrenceTree.phyla[i].classes.splice(undefinedClassIndex, 1)[0],
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (typeof occurrenceTree.phyla[i].phylum === "undefined") {
|
|
203
|
+
occurrenceTree.phyla[i].phylum = "Unranked taxa";
|
|
204
|
+
occurrenceTree.phyla[i].unranked = true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return occurrenceTree;
|
|
209
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export const addCommas = (x) => {
|
|
2
|
+
x = parseInt(x);
|
|
3
|
+
var parts = x.toString().split(".");
|
|
4
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5
|
+
return parts.join(".");
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const sum = (data, prop) => {
|
|
9
|
+
if (!data || !data.length) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return data
|
|
13
|
+
.map((d) => {
|
|
14
|
+
return d[prop];
|
|
15
|
+
})
|
|
16
|
+
.reduce((a, b) => {
|
|
17
|
+
return a + b;
|
|
18
|
+
}, 0);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const hexToRgb = (hex, opacity) => {
|
|
22
|
+
if (!hex) {
|
|
23
|
+
return "rgba(0,0,0,0.3)";
|
|
24
|
+
}
|
|
25
|
+
hex = hex.replace("#", "");
|
|
26
|
+
let bigint = parseInt(hex, 16);
|
|
27
|
+
let r = (bigint >> 16) & 255;
|
|
28
|
+
let g = (bigint >> 8) & 255;
|
|
29
|
+
let b = bigint & 255;
|
|
30
|
+
return `rgba(${r},${g},${b},${opacity || 0.8})`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type TimescaleDivision = {
|
|
34
|
+
name: string;
|
|
35
|
+
abbrev: string;
|
|
36
|
+
t_age: number;
|
|
37
|
+
b_age: number;
|
|
38
|
+
color: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const timescale: TimescaleDivision[] = [
|
|
42
|
+
{ name: "Quaternary", abbrev: "Q", t_age: 0, b_age: 2.588, color: "#F9F97F" },
|
|
43
|
+
{
|
|
44
|
+
name: "Neogene",
|
|
45
|
+
abbrev: "Ng",
|
|
46
|
+
t_age: 2.588,
|
|
47
|
+
b_age: 23.03,
|
|
48
|
+
color: "#FFE619",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "Paleogene",
|
|
52
|
+
abbrev: "Pg",
|
|
53
|
+
t_age: 23.03,
|
|
54
|
+
b_age: 66,
|
|
55
|
+
color: "#FD9A52",
|
|
56
|
+
},
|
|
57
|
+
{ name: "Cretaceous", abbrev: "K", t_age: 66, b_age: 145, color: "#7FC64E" },
|
|
58
|
+
{ name: "Jurassic", abbrev: "J", t_age: 145, b_age: 201.3, color: "#34B2C9" },
|
|
59
|
+
{
|
|
60
|
+
name: "Triassic",
|
|
61
|
+
abbrev: "Tr",
|
|
62
|
+
t_age: 201.3,
|
|
63
|
+
b_age: 252.17,
|
|
64
|
+
color: "#812B92",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "Permian",
|
|
68
|
+
abbrev: "P",
|
|
69
|
+
t_age: 252.17,
|
|
70
|
+
b_age: 298.9,
|
|
71
|
+
color: "#F04028",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "Carboniferous",
|
|
75
|
+
abbrev: "C",
|
|
76
|
+
t_age: 298.9,
|
|
77
|
+
b_age: 358.9,
|
|
78
|
+
color: "#67A599",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "Devonian",
|
|
82
|
+
abbrev: "D",
|
|
83
|
+
t_age: 358.9,
|
|
84
|
+
b_age: 419.2,
|
|
85
|
+
color: "#CB8C37",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "Silurian",
|
|
89
|
+
abbrev: "S",
|
|
90
|
+
t_age: 419.2,
|
|
91
|
+
b_age: 443.8,
|
|
92
|
+
color: "#B3E1B6",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "Ordovician",
|
|
96
|
+
abbrev: "O",
|
|
97
|
+
t_age: 443.8,
|
|
98
|
+
b_age: 485.4,
|
|
99
|
+
color: "#009270",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "Cambrian",
|
|
103
|
+
abbrev: "Cm",
|
|
104
|
+
t_age: 485.4,
|
|
105
|
+
b_age: 541,
|
|
106
|
+
color: "#7FA056",
|
|
107
|
+
},
|
|
108
|
+
{ name: "Ediacaran", abbrev: "E", t_age: 541, b_age: 635, color: "#FFC3E1" },
|
|
109
|
+
{
|
|
110
|
+
name: "Cryogenian",
|
|
111
|
+
abbrev: "Cr",
|
|
112
|
+
t_age: 635,
|
|
113
|
+
b_age: 720,
|
|
114
|
+
color: "#FFAFD7",
|
|
115
|
+
},
|
|
116
|
+
{ name: "Tonian", abbrev: "T", t_age: 720, b_age: 1000, color: "#FFA5D2" },
|
|
117
|
+
{ name: "Stenian", abbrev: "St", t_age: 1000, b_age: 1200, color: "#FFA5D2" },
|
|
118
|
+
{
|
|
119
|
+
name: "Ectasian",
|
|
120
|
+
abbrev: "Ec",
|
|
121
|
+
t_age: 1200,
|
|
122
|
+
b_age: 1400,
|
|
123
|
+
color: "#FF98CC",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "Calymmian",
|
|
127
|
+
abbrev: "Ca",
|
|
128
|
+
t_age: 1400,
|
|
129
|
+
b_age: 1600,
|
|
130
|
+
color: "#FF8BC5",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "Statherian",
|
|
134
|
+
abbrev: "St",
|
|
135
|
+
t_age: 1600,
|
|
136
|
+
b_age: 1800,
|
|
137
|
+
color: "#EE93C1",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "Orosirian",
|
|
141
|
+
abbrev: "Or",
|
|
142
|
+
t_age: 1800,
|
|
143
|
+
b_age: 2050,
|
|
144
|
+
color: "#E874AF",
|
|
145
|
+
},
|
|
146
|
+
{ name: "Rhyacian", abbrev: "R", t_age: 2050, b_age: 2300, color: "#EB84B8" },
|
|
147
|
+
{
|
|
148
|
+
name: "Siderian",
|
|
149
|
+
abbrev: "Sd",
|
|
150
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KAEnB,EAAS,CAAE,KAAM,mBAAoB,QAAS,CAAA,CAAK,GACnD,IAAgB,GAChB,cAAc,GAElB,EAAG,IACH,MAAO,IAAM,cAAc,EAC7B,EAAG,CAAC,EAAc,EAEX,IACT,CAEO,SAAS,0CAAkB,CAAA,SAChC,CAAQ,CAAA,gBACR,CAAe,CAAA,MACf,CAAK,CAKN,EAGC,MAFA,AAAA,CAAA,EAAA,6BAAA,YAAW,AAAX,EAAa,EAAU,GAEhB,IACT","sources":["<anon>","packages/map-interface/src/map-view.ts"],"sourcesContent":["require(\"./map-interface.3ea55e0c.js\");\nrequire(\"./map-interface.33b7734a.js\");\nrequire(\"./map-interface.713361a4.js\");\nvar $iE1eH$macrostrathyper = require(\"@macrostrat/hyper\");\nvar $iE1eH$macrostratmapboxreact = require(\"@macrostrat/mapbox-react\");\nvar $iE1eH$macrostratmapboxutils = require(\"@macrostrat/mapbox-utils\");\nvar $iE1eH$classnames = require(\"classnames\");\nvar $iE1eH$mapboxgl = require(\"mapbox-gl\");\nvar $iE1eH$react = require(\"react\");\nrequire(\"mapbox-gl/dist/mapbox-gl.css\");\nvar $iE1eH$macrostratuicomponents = require(\"@macrostrat/ui-components\");\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\n$parcel$export(module.exports, \"MapView\", () => $8c5236898eee97dc$export$ab1e7a67d6ec5ad8);\n$parcel$export(module.exports, \"MapTerrainManager\", () => $8c5236898eee97dc$export$cee395a8a2a00b29);\n\n\n\n\n\n\n\nvar $6ULxP = parcelRequire(\"6ULxP\");\n\nvar $7CmOU = parcelRequire(\"7CmOU\");\n\n\nvar $R3my3 = parcelRequire(\"R3my3\");\n\nconst $8c5236898eee97dc$var$h = (0, ($parcel$interopDefault($iE1eH$macrostrathyper))).styled((0, (/*@__PURE__*/$parcel$interopDefault($6ULxP))));\nfunction $8c5236898eee97dc$var$defaultInitializeMap(container, args = {}) {\n const { mapPosition: mapPosition, ...rest } = args;\n const map = new (0, ($parcel$interopDefault($iE1eH$mapboxgl))).Map({\n container: container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: false,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest\n });\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) // If no map positioning information is provided, we use the default\n _mapPosition = $8c5236898eee97dc$var$defaultMapPosition;\n // set initial map position\n if (_mapPosition != null) (0, $iE1eH$macrostratmapboxutils.setMapPosition)(map, _mapPosition);\n return map;\n}\nconst $8c5236898eee97dc$var$defaultMapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000\n }\n};\nfunction $8c5236898eee97dc$export$ab1e7a67d6ec5ad8(props) {\n let { terrainSourceID: terrainSourceID } = props;\n const { enableTerrain: enableTerrain = true, style: style, mapPosition: mapPosition, initializeMap: initializeMap = $8c5236898eee97dc$var$defaultInitializeMap, children: children, mapboxToken: mapboxToken, accessToken: // Deprecated\n accessToken, infoMarkerPosition: infoMarkerPosition, transformRequest: transformRequest, projection: projection, onMapLoaded: onMapLoaded = null, onStyleLoaded: onStyleLoaded = null, onMapMoved: onMapMoved = null, standalone: standalone = false, overlayStyles: overlayStyles, transformStyle: transformStyle, trackResize: trackResize = true, loadingIgnoredSources: loadingIgnoredSources = [\n \"elevationMarker\",\n \"crossSectionEndpoints\"\n ], id: id = \"map\", className: className, ...rest } = props;\n if (enableTerrain) terrainSourceID ?? (terrainSourceID = \"mapbox-3d-dem\");\n (0, $iE1eH$react.useEffect)(()=>{\n if (id != null) console.warn(\"Setting a specific element ID for the map is deprecated. Please use className instead.\");\n }, [\n id\n ]);\n const _mapboxToken = mapboxToken ?? accessToken;\n if (_mapboxToken != null) (0, ($parcel$interopDefault($iE1eH$mapboxgl))).accessToken = _mapboxToken;\n const dispatch = (0, $iE1eH$macrostratmapboxreact.useMapDispatch)();\n let mapRef = (0, $iE1eH$macrostratmapboxreact.useMapRef)();\n const ref = (0, $iE1eH$react.useRef)();\n const parentRef = (0, $iE1eH$react.useRef)();\n const [baseStyle, setBaseStyle] = (0, $iE1eH$react.useState)(null);\n const estMapPosition = mapRef.current == null ? mapPosition : (0, $iE1eH$macrostratmapboxutils.getMapPosition)(mapRef.current);\n const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $iE1eH$macrostratmapboxutils.mapViewInfo)(estMapPosition);\n const is3DAvailable = (mapUse3D ?? false) && enableTerrain;\n (0, $iE1eH$react.useEffect)(()=>{\n /** Manager to update map style */ if (baseStyle == null) return;\n let map = mapRef.current;\n let newStyle = baseStyle;\n const overlayStyles = props.overlayStyles ?? [];\n if (overlayStyles.length > 0) newStyle = (0, $iE1eH$macrostratmapboxutils.mergeStyles)(newStyle, ...overlayStyles);\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */ if (is3DAvailable) {\n // We can update the style with terrain layers immediately\n const terrainStyle = (0, $iE1eH$macrostratmapboxreact.getTerrainLayerForStyle)(newStyle, terrainSourceID);\n newStyle = (0, $iE1eH$macrostratmapboxutils.mergeStyles)(newStyle, terrainStyle);\n }\n if (transformStyle != null) newStyle = transformStyle(newStyle);\n if (map != null) {\n dispatch({\n type: \"set-style-loaded\",\n payload: false\n });\n map.setStyle(newStyle);\n } else {\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection: projection,\n mapPosition: mapPosition,\n transformRequest: transformRequest,\n ...rest\n });\n dispatch({\n type: \"set-map\",\n payload: map\n });\n map.setPadding((0, $R3my3.getMapPadding)(ref, parentRef), {\n animate: false\n });\n onMapLoaded?.(map);\n }\n }, [\n baseStyle,\n overlayStyles,\n transformStyle\n ]);\n (0, $iE1eH$macrostratuicomponents.useAsyncEffect)(async ()=>{\n /** Manager to update map style */ let newStyle;\n if (typeof style === \"string\") newStyle = await (0, $iE1eH$macrostratmapboxutils.getMapboxStyle)(style, {\n access_token: (0, ($parcel$interopDefault($iE1eH$mapboxgl))).accessToken\n });\n else newStyle = style;\n setBaseStyle(newStyle);\n }, [\n style\n ]);\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n const mapClassName = (0, ($parcel$interopDefault($iE1eH$classnames)))({\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": is3DAvailable\n }, `${_projection}-projection`);\n const parentClassName = (0, ($parcel$interopDefault($iE1eH$classnames)))({\n standalone: standalone\n }, className);\n return $8c5236898eee97dc$var$h(\"div.map-view-container.main-view\", {\n ref: parentRef,\n className: parentClassName\n }, [\n $8c5236898eee97dc$var$h(\"div.mapbox-map.map-view\", {\n ref: ref,\n className: mapClassName,\n id: id\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapLoadingReporter), {\n ignoredSources: loadingIgnoredSources\n }),\n $8c5236898eee97dc$var$h($8c5236898eee97dc$var$StyleLoadedReporter, {\n onStyleLoaded: onStyleLoaded\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapMovedReporter), {\n onMapMoved: onMapMoved\n }),\n // Subsitute for trackResize: true that allows map resizing to\n // be tied to a specific ref component\n $8c5236898eee97dc$var$h.if(trackResize)((0, $7CmOU.MapResizeManager), {\n containerRef: ref\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapPaddingManager), {\n containerRef: ref,\n parentRef: parentRef,\n infoMarkerPosition: infoMarkerPosition\n }),\n $8c5236898eee97dc$var$h($8c5236898eee97dc$export$cee395a8a2a00b29, {\n mapUse3D: is3DAvailable,\n terrainSourceID: terrainSourceID,\n style: style\n }),\n children\n ]);\n}\nfunction $8c5236898eee97dc$var$StyleLoadedReporter({ onStyleLoaded: onStyleLoaded = null }) {\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */ const isStyleLoaded = (0, $iE1eH$macrostratmapboxreact.useMapStatus)((state)=>state.isStyleLoaded);\n const mapRef = (0, $iE1eH$macrostratmapboxreact.useMapRef)();\n const dispatch = (0, $iE1eH$macrostratmapboxreact.useMapDispatch)();\n (0, $iE1eH$react.useEffect)(()=>{\n if (isStyleLoaded) return;\n const interval = setInterval(()=>{\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({\n type: \"set-style-loaded\",\n payload: true\n });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return ()=>clearInterval(interval);\n }, [\n isStyleLoaded\n ]);\n return null;\n}\nfunction $8c5236898eee97dc$export$cee395a8a2a00b29({ mapUse3D: mapUse3D, terrainSourceID: terrainSourceID, style: style }) {\n (0, $iE1eH$macrostratmapboxreact.use3DTerrain)(mapUse3D, terrainSourceID);\n return null;\n}\n\n\n//# sourceMappingURL=map-interface.7295b0a2.js.map\n","import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-react\";\nimport React from \"react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt,\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.StyleSpecification>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (\n style: mapboxgl.StyleSpecification,\n ) => mapboxgl.StyleSpecification;\n loadingIgnoredSources?: string[];\n id?: string;\n className?: string;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: false,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n trackResize = true,\n loadingIgnoredSources = [\"elevationMarker\", \"crossSectionEndpoints\"],\n id = \"map\",\n className,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n useEffect(() => {\n if (id != null) {\n console.warn(\n \"Setting a specific element ID for the map is deprecated. Please use className instead.\",\n );\n }\n }, [id]);\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n\n const estMapPosition: MapPosition | null =\n mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);\n const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);\n const is3DAvailable = (mapUse3D ?? false) && enableTerrain;\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n let newStyle: mapboxgl.StyleSpecification = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n if (is3DAvailable) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, transformStyle]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.StyleSpecification;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const mapClassName = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": is3DAvailable,\n },\n `${_projection}-projection`,\n );\n\n const parentClassName = classNames(\n {\n standalone,\n },\n className,\n );\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map.map-view\", { ref, className: mapClassName, id }),\n h(MapLoadingReporter, {\n ignoredSources: loadingIgnoredSources,\n }),\n h(StyleLoadedReporter, { onStyleLoaded }),\n h(MapMovedReporter, { onMapMoved }),\n // Subsitute for trackResize: true that allows map resizing to\n // be tied to a specific ref component\n h.if(trackResize)(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D: is3DAvailable, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nfunction StyleLoadedReporter({ onStyleLoaded = null }) {\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n const mapRef = useMapRef();\n const dispatch = useMapDispatch();\n\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n return null;\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.StyleSpecification | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":["require","$iE1eH$macrostrathyper","$iE1eH$macrostratmapboxreact","$iE1eH$macrostratmapboxutils","$iE1eH$classnames","$iE1eH$mapboxgl","$iE1eH$react","$iE1eH$macrostratuicomponents","$parcel$interopDefault","a","__esModule","default","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$8c5236898eee97dc$export$ab1e7a67d6ec5ad8","$8c5236898eee97dc$export$cee395a8a2a00b29","$6ULxP","$7CmOU","$R3my3","$8c5236898eee97dc$var$h","styled","$8c5236898eee97dc$var$defaultInitializeMap","container","args","mapPosition","rest","map","Map","maxZoom","logoPosition","trackResize","antialias","optimizeForTerrain","_mapPosition","center","bounds","$8c5236898eee97dc$var$defaultMapPosition","setMapPosition","camera","lat","lng","altitude","props","terrainSourceID","enableTerrain","style","initializeMap","children","mapboxToken","accessToken","infoMarkerPosition","transformRequest","projection","onMapLoaded","onStyleLoaded","onMapMoved","standalone","overlayStyles","transformStyle","loadingIgnoredSources","className","useEffect","console","warn","_mapboxToken","dispatch","useMapDispatch","mapRef","useMapRef","ref","useRef","parentRef","baseStyle","setBaseStyle","useState","estMapPosition","current","getMapPosition","mapUse3D","mapIsRotated","mapViewInfo","is3DAvailable","newStyle","length","mergeStyles","terrainStyle","getTerrainLayerForStyle","type","payload","setStyle","setPadding","getMapPadding","animate","useAsyncEffect","getMapboxStyle","access_token","_projection","getProjection","name","mapClassName","MapLoadingReporter","ignoredSources","$8c5236898eee97dc$var$StyleLoadedReporter","MapMovedReporter","if","MapResizeManager","containerRef","MapPaddingManager","isStyleLoaded","useMapStatus","state","interval","setInterval","clearInterval","use3DTerrain"],"version":3,"file":"map-interface.7295b0a2.js.map","sourceRoot":"../../../../"}
|