@macrostrat/map-interface 1.0.12 → 1.2.0
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 +13 -0
- package/dist/cjs/container.72611900.js +134 -0
- package/dist/cjs/container.72611900.js.map +1 -0
- package/dist/cjs/context-panel.8c4b009c.js +88 -0
- package/dist/cjs/context-panel.8c4b009c.js.map +1 -0
- package/dist/cjs/controls.7ce3e95c.js +79 -0
- package/dist/cjs/controls.7ce3e95c.js.map +1 -0
- package/dist/cjs/dev.7499151f.js +33 -0
- package/dist/cjs/dev.7499151f.js.map +1 -0
- package/dist/cjs/expansion-panel.08532cee.js +134 -0
- package/dist/cjs/expansion-panel.08532cee.js.map +1 -0
- package/dist/cjs/hash-string.62e84f08.js +67 -0
- package/dist/cjs/hash-string.62e84f08.js.map +1 -0
- package/dist/cjs/header.58c5c012.js +104 -0
- package/dist/cjs/header.58c5c012.js.map +1 -0
- package/dist/cjs/headers.20eae5f7.js +29 -0
- package/dist/cjs/headers.20eae5f7.js.map +1 -0
- package/dist/cjs/helpers.0f72ddaf.js +190 -0
- package/dist/cjs/helpers.0f72ddaf.js.map +1 -0
- package/dist/cjs/index.js +51 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/location-info.92e70042.js +119 -0
- package/dist/cjs/location-info.92e70042.js.map +1 -0
- package/dist/cjs/location-panel.c95f5e96.js +66 -0
- package/dist/cjs/location-panel.c95f5e96.js.map +1 -0
- package/dist/cjs/main.module.02c4de16.css +86 -0
- package/dist/cjs/main.module.02c4de16.css.map +1 -0
- package/dist/cjs/main.module.3f2b7c9f.js +38 -0
- package/dist/cjs/main.module.3f2b7c9f.js.map +1 -0
- package/dist/cjs/main.module.4ecbaaa5.js +62 -0
- package/dist/cjs/main.module.4ecbaaa5.js.map +1 -0
- package/dist/cjs/main.module.62939ea7.js +167 -0
- package/dist/cjs/main.module.62939ea7.js.map +1 -0
- package/dist/cjs/main.module.92978d8b.css +52 -0
- package/dist/cjs/main.module.92978d8b.css.map +1 -0
- package/dist/cjs/main.module.becc2fe7.css +92 -0
- package/dist/cjs/main.module.becc2fe7.css.map +1 -0
- package/dist/cjs/main.module.ccec47df.js +50 -0
- package/dist/cjs/main.module.ccec47df.js.map +1 -0
- package/dist/cjs/main.module.e958948e.js +26 -0
- package/dist/cjs/main.module.e958948e.js.map +1 -0
- package/dist/{index.css → cjs/main.module.f085a193.css} +9 -397
- package/dist/cjs/main.module.f085a193.css.map +1 -0
- package/dist/cjs/main.module.ff1b1aca.css +179 -0
- package/dist/cjs/main.module.ff1b1aca.css.map +1 -0
- package/dist/cjs/map-page.190b6723.js +182 -0
- package/dist/cjs/map-page.190b6723.js.map +1 -0
- package/dist/cjs/map-view.93363b41.js +167 -0
- package/dist/cjs/map-view.93363b41.js.map +1 -0
- package/dist/cjs/terrain.90f76b4e.js +59 -0
- package/dist/cjs/terrain.90f76b4e.js.map +1 -0
- package/dist/cjs/tile-extent.06a4b2ed.js +51 -0
- package/dist/cjs/tile-extent.06a4b2ed.js.map +1 -0
- package/dist/cjs/utils.09cef979.js +36 -0
- package/dist/cjs/utils.09cef979.js.map +1 -0
- package/dist/cjs/utils.26f02633.js +46 -0
- package/dist/cjs/utils.26f02633.js.map +1 -0
- package/dist/cjs/vector-tile-features.456f887b.js +268 -0
- package/dist/cjs/vector-tile-features.456f887b.js.map +1 -0
- package/dist/cjs/xray.a23f8660.js +89 -0
- package/dist/cjs/xray.a23f8660.js.map +1 -0
- package/dist/esm/container.16bde261.js +126 -0
- package/dist/esm/container.16bde261.js.map +1 -0
- package/dist/esm/context-panel.c288c5cd.js +81 -0
- package/dist/esm/context-panel.c288c5cd.js.map +1 -0
- package/dist/esm/controls.f757ce16.js +74 -0
- package/dist/esm/controls.f757ce16.js.map +1 -0
- package/dist/esm/dev.ccb6e774.js +13 -0
- package/dist/esm/dev.ccb6e774.js.map +1 -0
- package/dist/esm/expansion-panel.feff0e62.js +123 -0
- package/dist/esm/expansion-panel.feff0e62.js.map +1 -0
- package/dist/esm/hash-string.836601b2.js +61 -0
- package/dist/esm/hash-string.836601b2.js.map +1 -0
- package/dist/esm/header.0f535ab1.js +99 -0
- package/dist/esm/header.0f535ab1.js.map +1 -0
- package/dist/esm/headers.b25ff414.js +24 -0
- package/dist/esm/headers.b25ff414.js.map +1 -0
- package/dist/esm/helpers.fb1d7227.js +176 -0
- package/dist/esm/helpers.fb1d7227.js.map +1 -0
- package/dist/{types.d.ts → esm/index.d.ts} +104 -52
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +25 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/location-info.5543bb05.js +89 -0
- package/dist/esm/location-info.5543bb05.js.map +1 -0
- package/dist/esm/location-panel.0b1f4ed2.js +58 -0
- package/dist/esm/location-panel.0b1f4ed2.js.map +1 -0
- package/dist/esm/main.module.5eb366de.js +52 -0
- package/dist/esm/main.module.5eb366de.js.map +1 -0
- package/dist/esm/main.module.67a908da.js +40 -0
- package/dist/esm/main.module.67a908da.js.map +1 -0
- package/dist/esm/main.module.89579666.js +64 -0
- package/dist/esm/main.module.89579666.js.map +1 -0
- package/dist/esm/main.module.9c57cc95.js +28 -0
- package/dist/esm/main.module.9c57cc95.js.map +1 -0
- package/dist/esm/main.module.f70e002b.js +169 -0
- package/dist/esm/main.module.f70e002b.js.map +1 -0
- package/dist/esm/map-page.b953c404.js +175 -0
- package/dist/esm/map-page.b953c404.js.map +1 -0
- package/dist/esm/map-view.a3fe6257.js +161 -0
- package/dist/esm/map-view.a3fe6257.js.map +1 -0
- package/dist/esm/terrain.f65cf7c5.js +54 -0
- package/dist/esm/terrain.f65cf7c5.js.map +1 -0
- package/dist/esm/tile-extent.ca526996.js +46 -0
- package/dist/esm/tile-extent.ca526996.js.map +1 -0
- package/dist/esm/utils.122d1f2d.js +28 -0
- package/dist/esm/utils.122d1f2d.js.map +1 -0
- package/dist/esm/utils.d40349f0.js +40 -0
- package/dist/esm/utils.d40349f0.js.map +1 -0
- package/dist/esm/vector-tile-features.e1a24df0.js +258 -0
- package/dist/esm/vector-tile-features.e1a24df0.js.map +1 -0
- package/dist/esm/xray.c0663c25.js +83 -0
- package/dist/esm/xray.c0663c25.js.map +1 -0
- package/package.json +19 -36
- package/src/container.ts +29 -21
- package/src/context-panel/index.ts +7 -8
- package/src/context-panel/main.module.sass +1 -1
- package/src/dev/main.module.sass +16 -0
- package/src/dev/map-page.ts +32 -11
- package/src/dev/vector-tile-features.ts +44 -13
- package/src/helpers.ts +15 -13
- package/src/location-panel/header.ts +27 -8
- package/src/location-panel/index.ts +4 -2
- package/src/location-panel/main.module.sass +7 -0
- package/src/main.module.sass +4 -1
- package/src/map-view/index.ts +28 -32
- package/dist/index.cjs.css +0 -961
- package/dist/index.cjs.css.map +0 -1
- package/dist/index.cjs.js +0 -1965
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -1956
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
var $8646508ae99a5857$exports = require("./xray.a23f8660.js");
|
|
2
|
+
var $c3311f59335df34d$exports = require("./container.72611900.js");
|
|
3
|
+
var $fce5fc950d1fe35b$exports = require("./context-panel.8c4b009c.js");
|
|
4
|
+
var $2611a7b4364593e5$exports = require("./helpers.0f72ddaf.js");
|
|
5
|
+
var $2bc7c1e4e7da7fdf$exports = require("./location-panel.c95f5e96.js");
|
|
6
|
+
var $12b6032029db16d4$exports = require("./map-view.93363b41.js");
|
|
7
|
+
var $33088e8384af337c$exports = require("./main.module.ccec47df.js");
|
|
8
|
+
require("./main.module.becc2fe7.css");
|
|
9
|
+
var $abbe8d0af34cbbed$exports = require("./tile-extent.06a4b2ed.js");
|
|
10
|
+
var $db14eb7a5c07abdb$exports = require("./vector-tile-features.456f887b.js");
|
|
11
|
+
var $g1A1s$blueprintjscore = require("@blueprintjs/core");
|
|
12
|
+
var $g1A1s$macrostrathyper = require("@macrostrat/hyper");
|
|
13
|
+
var $g1A1s$macrostratuicomponents = require("@macrostrat/ui-components");
|
|
14
|
+
var $g1A1s$mapboxgl = require("mapbox-gl");
|
|
15
|
+
var $g1A1s$react = require("react");
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $parcel$interopDefault(a) {
|
|
19
|
+
return a && a.__esModule ? a.default : a;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function $parcel$export(e, n, v, s) {
|
|
23
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
$parcel$export(module.exports, "h", () => $6f5ca387ac26c0b5$export$dda1d9f60106f0e9);
|
|
27
|
+
$parcel$export(module.exports, "MapInspectorV2", () => $6f5ca387ac26c0b5$export$eab3034e57b46e26);
|
|
28
|
+
$parcel$export(module.exports, "DevMapPage", () => $6f5ca387ac26c0b5$export$2391061fbdfb71ef);
|
|
29
|
+
// Import other components
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const $6f5ca387ac26c0b5$export$dda1d9f60106f0e9 = (0, ($parcel$interopDefault($g1A1s$macrostrathyper))).styled((0, ($parcel$interopDefault($33088e8384af337c$exports))));
|
|
45
|
+
function $6f5ca387ac26c0b5$export$eab3034e57b46e26({ title: title = "Map inspector", headerElement: headerElement = null, transformRequest: transformRequest = null, mapPosition: mapPosition = null, mapboxToken: mapboxToken = null, overlayStyle: overlayStyle = null, controls: controls = null, children: children = null, style: style, bounds: bounds = null, focusedSource: focusedSource = null, focusedSourceTitle: focusedSourceTitle = null, fitViewport: fitViewport = true, styleType: styleType = "macrostrat" }) {
|
|
46
|
+
/* We apply a custom style to the panel container when we are interacting
|
|
47
|
+
with the search bar, so that we can block map interactions until search
|
|
48
|
+
bar focus is lost.
|
|
49
|
+
We also apply a custom style when the infodrawer is open so we can hide
|
|
50
|
+
the search bar on mobile platforms
|
|
51
|
+
*/ const dark = (0, $g1A1s$macrostratuicomponents.useDarkMode)();
|
|
52
|
+
const isEnabled = dark?.isEnabled;
|
|
53
|
+
if (mapboxToken != null) (0, ($parcel$interopDefault($g1A1s$mapboxgl))).accessToken = mapboxToken;
|
|
54
|
+
if (styleType == "macrostrat") style ??= isEnabled ? "mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true" : "mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true";
|
|
55
|
+
else style ??= isEnabled ? "mapbox://styles/mapbox/dark-v10" : "mapbox://styles/mapbox/light-v10";
|
|
56
|
+
const [isOpen, setOpen] = (0, $g1A1s$react.useState)(false);
|
|
57
|
+
const [state, setState] = (0, $g1A1s$macrostratuicomponents.useStoredState)("macrostrat:dev-map-page", {
|
|
58
|
+
showTileExtent: false,
|
|
59
|
+
xRay: false
|
|
60
|
+
});
|
|
61
|
+
const { showTileExtent: showTileExtent, xRay: xRay } = state;
|
|
62
|
+
const [actualStyle, setActualStyle] = (0, $g1A1s$react.useState)(null);
|
|
63
|
+
(0, $g1A1s$react.useEffect)(()=>{
|
|
64
|
+
(0, $8646508ae99a5857$exports.buildInspectorStyle)(style, overlayStyle, {
|
|
65
|
+
mapboxToken: mapboxToken,
|
|
66
|
+
inDarkMode: isEnabled,
|
|
67
|
+
xRay: xRay
|
|
68
|
+
}).then(setActualStyle);
|
|
69
|
+
}, [
|
|
70
|
+
style,
|
|
71
|
+
xRay,
|
|
72
|
+
mapboxToken,
|
|
73
|
+
isEnabled,
|
|
74
|
+
overlayStyle
|
|
75
|
+
]);
|
|
76
|
+
const [inspectPosition, setInspectPosition] = (0, $g1A1s$react.useState)(null);
|
|
77
|
+
const [data, setData] = (0, $g1A1s$react.useState)(null);
|
|
78
|
+
const onSelectPosition = (0, $g1A1s$react.useCallback)((position)=>{
|
|
79
|
+
setInspectPosition(position);
|
|
80
|
+
}, []);
|
|
81
|
+
let detailElement = null;
|
|
82
|
+
if (inspectPosition != null) detailElement = $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $2bc7c1e4e7da7fdf$exports.LocationPanel), {
|
|
83
|
+
onClose () {
|
|
84
|
+
setInspectPosition(null);
|
|
85
|
+
},
|
|
86
|
+
position: inspectPosition
|
|
87
|
+
}, [
|
|
88
|
+
$6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $db14eb7a5c07abdb$exports.TileInfo), {
|
|
89
|
+
feature: data?.[0] ?? null,
|
|
90
|
+
showExtent: showTileExtent,
|
|
91
|
+
setShowExtent () {
|
|
92
|
+
setState({
|
|
93
|
+
...state,
|
|
94
|
+
showTileExtent: !showTileExtent
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
$6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $db14eb7a5c07abdb$exports.FeaturePanel), {
|
|
99
|
+
features: data,
|
|
100
|
+
focusedSource: focusedSource,
|
|
101
|
+
focusedSourceTitle: focusedSourceTitle
|
|
102
|
+
})
|
|
103
|
+
]);
|
|
104
|
+
let tile = null;
|
|
105
|
+
if (showTileExtent && data?.[0] != null) {
|
|
106
|
+
let f = data[0];
|
|
107
|
+
tile = {
|
|
108
|
+
x: f._x,
|
|
109
|
+
y: f._y,
|
|
110
|
+
z: f._z
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $c3311f59335df34d$exports.MapAreaContainer), {
|
|
114
|
+
navbar: $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $fce5fc950d1fe35b$exports.FloatingNavbar), {
|
|
115
|
+
rightElement: $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $fce5fc950d1fe35b$exports.MapLoadingButton), {
|
|
116
|
+
large: true,
|
|
117
|
+
active: isOpen,
|
|
118
|
+
onClick: ()=>setOpen(!isOpen),
|
|
119
|
+
style: {
|
|
120
|
+
marginRight: "-5px"
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
headerElement: headerElement,
|
|
124
|
+
title: title
|
|
125
|
+
}),
|
|
126
|
+
contextPanel: $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $c3311f59335df34d$exports.PanelCard), [
|
|
127
|
+
controls,
|
|
128
|
+
$6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $g1A1s$blueprintjscore.Switch), {
|
|
129
|
+
checked: xRay,
|
|
130
|
+
label: "X-ray mode",
|
|
131
|
+
onChange () {
|
|
132
|
+
setState({
|
|
133
|
+
...state,
|
|
134
|
+
xRay: !xRay
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
]),
|
|
139
|
+
detailPanel: detailElement,
|
|
140
|
+
contextPanelOpen: isOpen,
|
|
141
|
+
fitViewport: fitViewport
|
|
142
|
+
}, $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $12b6032029db16d4$exports.MapView), {
|
|
143
|
+
style: actualStyle,
|
|
144
|
+
transformRequest: transformRequest,
|
|
145
|
+
mapPosition: mapPosition,
|
|
146
|
+
projection: {
|
|
147
|
+
name: "globe"
|
|
148
|
+
},
|
|
149
|
+
mapboxToken: mapboxToken,
|
|
150
|
+
bounds: bounds
|
|
151
|
+
}, [
|
|
152
|
+
$6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $db14eb7a5c07abdb$exports.FeatureSelectionHandler), {
|
|
153
|
+
selectedLocation: inspectPosition,
|
|
154
|
+
setFeatures: setData
|
|
155
|
+
}),
|
|
156
|
+
$6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $2611a7b4364593e5$exports.MapMarker), {
|
|
157
|
+
position: inspectPosition,
|
|
158
|
+
setPosition: onSelectPosition
|
|
159
|
+
}),
|
|
160
|
+
$6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $abbe8d0af34cbbed$exports.TileExtentLayer), {
|
|
161
|
+
tile: tile,
|
|
162
|
+
color: isEnabled ? "white" : "black"
|
|
163
|
+
}),
|
|
164
|
+
children
|
|
165
|
+
]));
|
|
166
|
+
}
|
|
167
|
+
function $6f5ca387ac26c0b5$var$MapInspector(props) {
|
|
168
|
+
const { children: children, controls: controls, ...rest } = props;
|
|
169
|
+
/** Compatibility wrapper for MapInspectorV2 */ // React warning about this legacy usage
|
|
170
|
+
console.warn("MapInspector is deprecated. Use MapInspectorV2 instead");
|
|
171
|
+
return $6f5ca387ac26c0b5$export$dda1d9f60106f0e9($6f5ca387ac26c0b5$export$eab3034e57b46e26, {
|
|
172
|
+
...rest,
|
|
173
|
+
controls: [
|
|
174
|
+
children,
|
|
175
|
+
controls
|
|
176
|
+
]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const $6f5ca387ac26c0b5$export$2391061fbdfb71ef = $6f5ca387ac26c0b5$var$MapInspector;
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=map-page.190b6723.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","sources":["packages/map-interface/src/dev/map-page.ts"],"sourcesContent":["// Import other components\nimport { Switch } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport { Spacer, useDarkMode, useStoredState } from \"@macrostrat/ui-components\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useCallback, useState, useEffect } from \"react\";\nimport { buildInspectorStyle } from \"./xray\";\nimport { MapAreaContainer, PanelCard } from \"../container\";\nimport { FloatingNavbar, MapLoadingButton } from \"../context-panel\";\nimport { MapMarker } from \"../helpers\";\nimport { LocationPanel } from \"../location-panel\";\nimport { MapView } from \"../map-view\";\nimport styles from \"./main.module.sass\";\nimport { TileExtentLayer } from \"./tile-extent\";\nimport {\n FeaturePanel,\n FeatureSelectionHandler,\n TileInfo,\n} from \"./vector-tile-features\";\nimport { MapPosition } from \"@macrostrat/mapbox-utils\";\n\nexport const h = hyper.styled(styles);\n\nexport function MapInspectorV2({\n title = \"Map inspector\",\n headerElement = null,\n transformRequest = null,\n mapPosition = null,\n mapboxToken = null,\n overlayStyle = null,\n controls = null,\n children = null,\n style,\n bounds = null,\n focusedSource = null,\n focusedSourceTitle = null,\n fitViewport = true,\n styleType = \"macrostrat\",\n}: {\n headerElement?: React.ReactNode;\n transformRequest?: mapboxgl.TransformRequestFunction;\n title?: string;\n style?: mapboxgl.Style | string;\n controls?: React.ReactNode;\n children?: React.ReactNode;\n mapboxToken?: string;\n overlayStyle?: mapboxgl.Style | string;\n focusedSource?: string;\n focusedSourceTitle?: string;\n projection?: string;\n mapPosition?: MapPosition;\n bounds?: [number, number, number, number];\n fitViewport?: boolean;\n styleType?: \"standard\" | \"macrostrat\";\n}) {\n /* We apply a custom style to the panel container when we are interacting\n with the search bar, so that we can block map interactions until search\n bar focus is lost.\n We also apply a custom style when the infodrawer is open so we can hide\n the search bar on mobile platforms\n */\n\n const dark = useDarkMode();\n const isEnabled = dark?.isEnabled;\n\n if (mapboxToken != null) {\n mapboxgl.accessToken = mapboxToken;\n }\n\n if (styleType == \"macrostrat\") {\n style ??= isEnabled\n ? \"mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true\"\n : \"mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true\";\n } else {\n style ??= isEnabled\n ? \"mapbox://styles/mapbox/dark-v10\"\n : \"mapbox://styles/mapbox/light-v10\";\n }\n\n const [isOpen, setOpen] = useState(false);\n\n const [state, setState] = useStoredState(\"macrostrat:dev-map-page\", {\n showTileExtent: false,\n xRay: false,\n });\n const { showTileExtent, xRay } = state;\n\n const [actualStyle, setActualStyle] = useState(null);\n\n useEffect(() => {\n buildInspectorStyle(style, overlayStyle, {\n mapboxToken,\n inDarkMode: isEnabled,\n xRay,\n }).then(setActualStyle);\n }, [style, xRay, mapboxToken, isEnabled, overlayStyle]);\n\n const [inspectPosition, setInspectPosition] =\n useState<mapboxgl.LngLat | null>(null);\n\n const [data, setData] = useState(null);\n\n const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {\n setInspectPosition(position);\n }, []);\n\n let detailElement = null;\n if (inspectPosition != null) {\n detailElement = h(\n LocationPanel,\n {\n onClose() {\n setInspectPosition(null);\n },\n position: inspectPosition,\n },\n [\n h(TileInfo, {\n feature: data?.[0] ?? null,\n showExtent: showTileExtent,\n setShowExtent() {\n setState({ ...state, showTileExtent: !showTileExtent });\n },\n }),\n h(FeaturePanel, { features: data, focusedSource, focusedSourceTitle }),\n ]\n );\n }\n\n let tile = null;\n if (showTileExtent && data?.[0] != null) {\n let f = data[0];\n tile = { x: f._x, y: f._y, z: f._z };\n }\n\n return h(\n MapAreaContainer,\n {\n navbar: h(FloatingNavbar, {\n rightElement: h(MapLoadingButton, {\n large: true,\n active: isOpen,\n onClick: () => setOpen(!isOpen),\n style: {\n marginRight: \"-5px\",\n },\n }),\n headerElement,\n title,\n }),\n contextPanel: h(PanelCard, [\n controls,\n h(Switch, {\n checked: xRay,\n label: \"X-ray mode\",\n onChange() {\n setState({ ...state, xRay: !xRay });\n },\n }),\n ]),\n detailPanel: detailElement,\n contextPanelOpen: isOpen,\n fitViewport,\n },\n h(\n MapView,\n {\n style: actualStyle,\n transformRequest,\n mapPosition,\n projection: { name: \"globe\" },\n mapboxToken,\n bounds,\n },\n [\n h(FeatureSelectionHandler, {\n selectedLocation: inspectPosition,\n setFeatures: setData,\n }),\n h(MapMarker, {\n position: inspectPosition,\n setPosition: onSelectPosition,\n }),\n h(TileExtentLayer, { tile, color: isEnabled ? \"white\" : \"black\" }),\n children,\n ]\n )\n );\n}\n\nfunction MapInspector(props) {\n const { children, controls, ...rest } = props;\n /** Compatibility wrapper for MapInspectorV2 */\n // React warning about this legacy usage\n console.warn(\"MapInspector is deprecated. Use MapInspectorV2 instead\");\n\n return h(MapInspectorV2, {\n ...rest,\n controls: [children, controls],\n });\n}\n\n// Legacy export\nexport const DevMapPage = MapInspector;\n"],"names":[],"version":3,"file":"map-page.190b6723.js.map"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var $35f1bc0112883d51$exports = require("./main.module.62939ea7.js");
|
|
2
|
+
require("./main.module.f085a193.css");
|
|
3
|
+
var $ecfbeec2ae4211a4$exports = require("./terrain.90f76b4e.js");
|
|
4
|
+
var $2611a7b4364593e5$exports = require("./helpers.0f72ddaf.js");
|
|
5
|
+
var $3490fc4f4bda12f7$exports = require("./utils.26f02633.js");
|
|
6
|
+
var $3Vvow$macrostrathyper = require("@macrostrat/hyper");
|
|
7
|
+
var $3Vvow$macrostratmapboxreact = require("@macrostrat/mapbox-react");
|
|
8
|
+
var $3Vvow$macrostratmapboxutils = require("@macrostrat/mapbox-utils");
|
|
9
|
+
var $3Vvow$classnames = require("classnames");
|
|
10
|
+
var $3Vvow$mapboxgl = require("mapbox-gl");
|
|
11
|
+
var $3Vvow$react = require("react");
|
|
12
|
+
require("mapbox-gl/dist/mapbox-gl.css");
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
function $parcel$interopDefault(a) {
|
|
16
|
+
return a && a.__esModule ? a.default : a;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function $parcel$export(e, n, v, s) {
|
|
20
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$parcel$export(module.exports, "MapView", () => $12b6032029db16d4$export$ab1e7a67d6ec5ad8);
|
|
24
|
+
$parcel$export(module.exports, "MapTerrainManager", () => $12b6032029db16d4$export$cee395a8a2a00b29);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const $12b6032029db16d4$var$h = (0, ($parcel$interopDefault($3Vvow$macrostrathyper))).styled((0, ($parcel$interopDefault($35f1bc0112883d51$exports))));
|
|
37
|
+
function $12b6032029db16d4$var$defaultInitializeMap(container, args = {}) {
|
|
38
|
+
const { mapPosition: mapPosition, ...rest } = args;
|
|
39
|
+
console.log("Initializing map (default)", args);
|
|
40
|
+
const map = new (0, ($parcel$interopDefault($3Vvow$mapboxgl))).Map({
|
|
41
|
+
container: container,
|
|
42
|
+
maxZoom: 18,
|
|
43
|
+
//maxTileCacheSize: 0,
|
|
44
|
+
logoPosition: "bottom-left",
|
|
45
|
+
trackResize: true,
|
|
46
|
+
antialias: true,
|
|
47
|
+
optimizeForTerrain: true,
|
|
48
|
+
...rest
|
|
49
|
+
});
|
|
50
|
+
// set initial map position
|
|
51
|
+
if (mapPosition != null) (0, $3Vvow$macrostratmapboxutils.setMapPosition)(map, mapPosition);
|
|
52
|
+
//setMapPosition(map, mapPosition);
|
|
53
|
+
return map;
|
|
54
|
+
}
|
|
55
|
+
const $12b6032029db16d4$var$defaultMapPosition = {
|
|
56
|
+
camera: {
|
|
57
|
+
lat: 34,
|
|
58
|
+
lng: -120,
|
|
59
|
+
altitude: 300000
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function $12b6032029db16d4$export$ab1e7a67d6ec5ad8(props) {
|
|
63
|
+
let { terrainSourceID: terrainSourceID } = props;
|
|
64
|
+
const { enableTerrain: enableTerrain = true, style: style, mapPosition: mapPosition = $12b6032029db16d4$var$defaultMapPosition, initializeMap: initializeMap = $12b6032029db16d4$var$defaultInitializeMap, children: children, mapboxToken: mapboxToken, accessToken: // Deprecated
|
|
65
|
+
accessToken, infoMarkerPosition: infoMarkerPosition, transformRequest: transformRequest, projection: projection, onMapLoaded: onMapLoaded = null, onStyleLoaded: onStyleLoaded = null, onMapMoved: onMapMoved = null, ...rest } = props;
|
|
66
|
+
if (enableTerrain) terrainSourceID ??= "mapbox-3d-dem";
|
|
67
|
+
const _mapboxToken = mapboxToken ?? accessToken;
|
|
68
|
+
if (_mapboxToken != null) (0, ($parcel$interopDefault($3Vvow$mapboxgl))).accessToken = _mapboxToken;
|
|
69
|
+
const dispatch = (0, $3Vvow$macrostratmapboxreact.useMapDispatch)();
|
|
70
|
+
let mapRef = (0, $3Vvow$macrostratmapboxreact.useMapRef)();
|
|
71
|
+
const ref = (0, $3Vvow$react.useRef)();
|
|
72
|
+
const parentRef = (0, $3Vvow$react.useRef)();
|
|
73
|
+
(0, $3Vvow$react.useEffect)(()=>{
|
|
74
|
+
if (style == null) return;
|
|
75
|
+
let map = mapRef.current;
|
|
76
|
+
if (map != null) {
|
|
77
|
+
console.log("Setting style", style);
|
|
78
|
+
map.setStyle(style);
|
|
79
|
+
} else {
|
|
80
|
+
console.log("Initializing map", style);
|
|
81
|
+
const map = initializeMap(ref.current, {
|
|
82
|
+
style: style,
|
|
83
|
+
projection: projection,
|
|
84
|
+
mapPosition: mapPosition,
|
|
85
|
+
transformRequest: transformRequest,
|
|
86
|
+
...rest
|
|
87
|
+
});
|
|
88
|
+
dispatch({
|
|
89
|
+
type: "set-map",
|
|
90
|
+
payload: map
|
|
91
|
+
});
|
|
92
|
+
map.setPadding((0, $3490fc4f4bda12f7$exports.getMapPadding)(ref, parentRef), {
|
|
93
|
+
animate: false
|
|
94
|
+
});
|
|
95
|
+
onMapLoaded?.(map);
|
|
96
|
+
}
|
|
97
|
+
const loadCallback = ()=>{
|
|
98
|
+
onStyleLoaded?.(map);
|
|
99
|
+
dispatch({
|
|
100
|
+
type: "set-style-loaded",
|
|
101
|
+
payload: true
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
map = mapRef.current;
|
|
105
|
+
if (map.isStyleLoaded()) // Catch a race condition where the style is loaded before the callback is set
|
|
106
|
+
loadCallback();
|
|
107
|
+
map.on("style.load", loadCallback);
|
|
108
|
+
return ()=>{
|
|
109
|
+
map.off("style.load", loadCallback);
|
|
110
|
+
};
|
|
111
|
+
}, [
|
|
112
|
+
style
|
|
113
|
+
]);
|
|
114
|
+
const _computedMapPosition = (0, $3Vvow$macrostratmapboxreact.useMapPosition)();
|
|
115
|
+
const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $3Vvow$macrostratmapboxutils.mapViewInfo)(_computedMapPosition);
|
|
116
|
+
// Get map projection
|
|
117
|
+
const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
|
|
118
|
+
const className = (0, ($parcel$interopDefault($3Vvow$classnames)))({
|
|
119
|
+
"is-rotated": mapIsRotated ?? false,
|
|
120
|
+
"is-3d-available": mapUse3D ?? false
|
|
121
|
+
}, `${_projection}-projection`);
|
|
122
|
+
return $12b6032029db16d4$var$h("div.map-view-container.main-view", {
|
|
123
|
+
ref: parentRef
|
|
124
|
+
}, [
|
|
125
|
+
$12b6032029db16d4$var$h("div.mapbox-map#map", {
|
|
126
|
+
ref: ref,
|
|
127
|
+
className: className
|
|
128
|
+
}),
|
|
129
|
+
$12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapLoadingReporter), {
|
|
130
|
+
ignoredSources: [
|
|
131
|
+
"elevationMarker",
|
|
132
|
+
"crossSectionEndpoints"
|
|
133
|
+
]
|
|
134
|
+
}),
|
|
135
|
+
$12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapMovedReporter), {
|
|
136
|
+
onMapMoved: onMapMoved
|
|
137
|
+
}),
|
|
138
|
+
$12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapResizeManager), {
|
|
139
|
+
containerRef: ref
|
|
140
|
+
}),
|
|
141
|
+
$12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapPaddingManager), {
|
|
142
|
+
containerRef: ref,
|
|
143
|
+
parentRef: parentRef,
|
|
144
|
+
infoMarkerPosition: infoMarkerPosition
|
|
145
|
+
}),
|
|
146
|
+
$12b6032029db16d4$var$h($12b6032029db16d4$export$cee395a8a2a00b29, {
|
|
147
|
+
mapUse3D: mapUse3D,
|
|
148
|
+
terrainSourceID: terrainSourceID
|
|
149
|
+
}),
|
|
150
|
+
children
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
function $12b6032029db16d4$export$cee395a8a2a00b29({ mapUse3D: mapUse3D, terrainSourceID: terrainSourceID }) {
|
|
154
|
+
const mapRef = (0, $3Vvow$macrostratmapboxreact.useMapRef)();
|
|
155
|
+
(0, $3Vvow$react.useEffect)(()=>{
|
|
156
|
+
const map = mapRef.current;
|
|
157
|
+
if (map == null) return;
|
|
158
|
+
(0, $ecfbeec2ae4211a4$exports.enable3DTerrain)(map, mapUse3D, terrainSourceID);
|
|
159
|
+
}, [
|
|
160
|
+
mapRef.current,
|
|
161
|
+
mapUse3D
|
|
162
|
+
]);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=map-view.93363b41.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","sources":["packages/map-interface/src/map-view/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useCallback } from \"react\";\nimport styles from \"../main.module.sass\";\nimport { enable3DTerrain } from \"./terrain\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"../helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"../utils\";\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}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n console.log(\"Initializing map (default)\", args);\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n //maxTileCacheSize: 0,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest,\n });\n\n // set initial map position\n if (mapPosition != null) {\n setMapPosition(map, mapPosition);\n }\n\n //setMapPosition(map, mapPosition);\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 = defaultMapPosition,\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 ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\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 useEffect(() => {\n if (style == null) return;\n let map = mapRef.current;\n if (map != null) {\n console.log(\"Setting style\", style);\n map.setStyle(style);\n } else {\n console.log(\"Initializing map\", style);\n const map = initializeMap(ref.current, {\n style,\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\n const loadCallback = () => {\n onStyleLoaded?.(map);\n dispatch({ type: \"set-style-loaded\", payload: true });\n };\n\n map = mapRef.current;\n if (map.isStyleLoaded()) {\n // Catch a race condition where the style is loaded before the callback is set\n loadCallback();\n }\n map.on(\"style.load\", loadCallback);\n return () => {\n map.off(\"style.load\", loadCallback);\n };\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`\n );\n\n return h(\"div.map-view-container.main-view\", { ref: parentRef }, [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, { containerRef: ref, parentRef, infoMarkerPosition }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID }),\n children,\n ]);\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n}) {\n const mapRef = useMapRef();\n\n useEffect(() => {\n const map = mapRef.current;\n if (map == null) return;\n enable3DTerrain(map, mapUse3D, terrainSourceID);\n }, [mapRef.current, mapUse3D]);\n return null;\n}\n"],"names":[],"version":3,"file":"map-view.93363b41.js.map"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
function $parcel$export(e, n, v, s) {
|
|
3
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$parcel$export(module.exports, "enable3DTerrain", () => $ecfbeec2ae4211a4$export$b730542ee281c4b1);
|
|
7
|
+
// We should merge this with code in @macrostrat/mapbox-react/src/terrain.ts:
|
|
8
|
+
function $ecfbeec2ae4211a4$export$b730542ee281c4b1(map, shouldEnable, sourceID = null) {
|
|
9
|
+
if (!map.style?._loaded) {
|
|
10
|
+
map.once("style.load", ()=>{
|
|
11
|
+
$ecfbeec2ae4211a4$export$b730542ee281c4b1(map, shouldEnable, sourceID);
|
|
12
|
+
});
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const currentTerrainSource = $ecfbeec2ae4211a4$var$getTerrainSourceID(map);
|
|
16
|
+
let demSourceID = sourceID ?? currentTerrainSource ?? "mapbox-dem";
|
|
17
|
+
console.log("Enabling 3D terrain with source", demSourceID);
|
|
18
|
+
// Enable or disable terrain depending on our current desires...
|
|
19
|
+
const currentTerrain = map.getTerrain();
|
|
20
|
+
if (!shouldEnable) {
|
|
21
|
+
if (currentTerrain != null) map.setTerrain(null);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (currentTerrain != null) return;
|
|
25
|
+
// Add a DEM source if one is not found already.
|
|
26
|
+
if (map.getSource(demSourceID) == null) map.addSource(demSourceID, {
|
|
27
|
+
type: "raster-dem",
|
|
28
|
+
url: "mapbox://mapbox.mapbox-terrain-dem-v1",
|
|
29
|
+
tileSize: 512,
|
|
30
|
+
maxzoom: 14
|
|
31
|
+
});
|
|
32
|
+
// add a sky layer that will show when the map is highly pitched
|
|
33
|
+
if (map.getLayer("sky") == null) map.addLayer({
|
|
34
|
+
id: "sky",
|
|
35
|
+
type: "sky",
|
|
36
|
+
paint: {
|
|
37
|
+
"sky-type": "atmosphere",
|
|
38
|
+
"sky-atmosphere-sun": [
|
|
39
|
+
0.0,
|
|
40
|
+
0.0
|
|
41
|
+
],
|
|
42
|
+
"sky-atmosphere-sun-intensity": 15
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
map.setTerrain({
|
|
46
|
+
source: demSourceID,
|
|
47
|
+
exaggeration: 1
|
|
48
|
+
});
|
|
49
|
+
console.log(map.getTerrain());
|
|
50
|
+
}
|
|
51
|
+
function $ecfbeec2ae4211a4$var$getTerrainSourceID(map) {
|
|
52
|
+
for (const [key, source] of Object.entries(map.getStyle().sources)){
|
|
53
|
+
if (source.type == "raster-dem") return key;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=terrain.90f76b4e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;AAAA,6EAA6E;AAEtE,SAAS,0CACd,GAAG,EACH,YAAqB,EACrB,WAA0B,IAAI;IAE9B,IAAI,CAAC,IAAI,KAAK,EAAE,SAAS;QACvB,IAAI,IAAI,CAAC,cAAc;YACrB,0CAAgB,KAAK,cAAc;QACrC;QACA;IACF;IAEA,MAAM,uBAAuB,yCAAmB;IAChD,IAAI,cAAc,YAAY,wBAAwB;IAEtD,QAAQ,GAAG,CAAC,mCAAmC;IAE/C,gEAAgE;IAChE,MAAM,iBAAiB,IAAI,UAAU;IAErC,IAAI,CAAC,cAAc;QACjB,IAAI,kBAAkB,MAAM,IAAI,UAAU,CAAC;QAC3C;IACF;IACA,IAAI,kBAAkB,MAAM;IAE5B,gDAAgD;IAChD,IAAI,IAAI,SAAS,CAAC,gBAAgB,MAChC,IAAI,SAAS,CAAC,aAAa;QACzB,MAAM;QACN,KAAK;QACL,UAAU;QACV,SAAS;IACX;IAGF,gEAAgE;IAChE,IAAI,IAAI,QAAQ,CAAC,UAAU,MACzB,IAAI,QAAQ,CAAC;QACX,IAAI;QACJ,MAAM;QACN,OAAO;YACL,YAAY;YACZ,sBAAsB;gBAAC;gBAAK;aAAI;YAChC,gCAAgC;QAClC;IACF;IAGF,IAAI,UAAU,CAAC;QAAE,QAAQ;QAAa,cAAc;IAAE;IACtD,QAAQ,GAAG,CAAC,IAAI,UAAU;AAC5B;AAEA,SAAS,yCAAmB,GAAG;IAC7B,KAAK,MAAM,CAAC,KAAK,OAAO,IAAI,OAAO,OAAO,CAAC,IAAI,QAAQ,GAAG,OAAO,EAAG;QAClE,IAAI,OAAO,IAAI,IAAI,cACjB,OAAO;IAEX;IACA,OAAO;AACT","sources":["packages/map-interface/src/map-view/terrain.ts"],"sourcesContent":["// We should merge this with code in @macrostrat/mapbox-react/src/terrain.ts:\n\nexport function enable3DTerrain(\n map,\n shouldEnable: boolean,\n sourceID: string | null = null\n) {\n if (!map.style?._loaded) {\n map.once(\"style.load\", () => {\n enable3DTerrain(map, shouldEnable, sourceID);\n });\n return;\n }\n\n const currentTerrainSource = getTerrainSourceID(map);\n let demSourceID = sourceID ?? currentTerrainSource ?? \"mapbox-dem\";\n\n console.log(\"Enabling 3D terrain with source\", demSourceID);\n\n // Enable or disable terrain depending on our current desires...\n const currentTerrain = map.getTerrain();\n\n if (!shouldEnable) {\n if (currentTerrain != null) map.setTerrain(null);\n return;\n }\n if (currentTerrain != null) return;\n\n // Add a DEM source if one is not found already.\n if (map.getSource(demSourceID) == null) {\n map.addSource(demSourceID, {\n type: \"raster-dem\",\n url: \"mapbox://mapbox.mapbox-terrain-dem-v1\",\n tileSize: 512,\n maxzoom: 14,\n });\n }\n\n // add a sky layer that will show when the map is highly pitched\n if (map.getLayer(\"sky\") == null) {\n map.addLayer({\n id: \"sky\",\n type: \"sky\",\n paint: {\n \"sky-type\": \"atmosphere\",\n \"sky-atmosphere-sun\": [0.0, 0.0],\n \"sky-atmosphere-sun-intensity\": 15,\n },\n });\n }\n\n map.setTerrain({ source: demSourceID, exaggeration: 1 });\n console.log(map.getTerrain());\n}\n\nfunction getTerrainSourceID(map) {\n for (const [key, source] of Object.entries(map.getStyle().sources)) {\n if (source.type == \"raster-dem\") {\n return key;\n }\n }\n return null;\n}\n"],"names":[],"version":3,"file":"terrain.90f76b4e.js.map"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var $eRYHH$macrostratmapboxreact = require("@macrostrat/mapbox-react");
|
|
2
|
+
var $eRYHH$mapboxtilebelt = require("@mapbox/tilebelt");
|
|
3
|
+
var $eRYHH$react = require("react");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "TileExtentLayer", () => $abbe8d0af34cbbed$export$86c09739b12f23cd);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function $abbe8d0af34cbbed$export$86c09739b12f23cd({ tile: tile, color: color = "red" }) {
|
|
15
|
+
const styleCallback = (0, $eRYHH$react.useCallback)((map, val)=>{
|
|
16
|
+
const style = map.getStyle();
|
|
17
|
+
if (style.layers == null) return;
|
|
18
|
+
style.layers = style.layers.filter((l)=>l.id != "tile-extent");
|
|
19
|
+
if (val == null) return map.setStyle(style);
|
|
20
|
+
const { x: x, y: y, z: z } = val;
|
|
21
|
+
const extent = (0, $eRYHH$mapboxtilebelt.tileToGeoJSON)([
|
|
22
|
+
x,
|
|
23
|
+
y,
|
|
24
|
+
z
|
|
25
|
+
]);
|
|
26
|
+
const source = {
|
|
27
|
+
type: "geojson",
|
|
28
|
+
data: extent
|
|
29
|
+
};
|
|
30
|
+
const layer = {
|
|
31
|
+
id: "tile-extent",
|
|
32
|
+
type: "line",
|
|
33
|
+
source: "tile-extent",
|
|
34
|
+
paint: {
|
|
35
|
+
"line-color": color,
|
|
36
|
+
"line-width": 2
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
style.sources["tile-extent"] = source;
|
|
40
|
+
style.layers.push(layer);
|
|
41
|
+
map.setStyle(style);
|
|
42
|
+
}, [
|
|
43
|
+
color
|
|
44
|
+
]);
|
|
45
|
+
const map = (0, $eRYHH$macrostratmapboxreact.useMapRef)();
|
|
46
|
+
(0, $eRYHH$macrostratmapboxreact.useMapConditionalStyle)(map, tile, styleCallback);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=tile-extent.06a4b2ed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAMO,SAAS,0CAAgB,QAC9B,IAAI,SACJ,QAAQ,OAIT;IACC,MAAM,gBAAgB,CAAA,GAAA,wBAAU,EAC9B,CAAC,KAAK;QACJ,MAAM,QAAQ,IAAI,QAAQ;QAC1B,IAAI,MAAM,MAAM,IAAI,MAAM;QAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAM,EAAE,EAAE,IAAI;QAClD,IAAI,OAAO,MACT,OAAO,IAAI,QAAQ,CAAC;QAEtB,MAAM,KAAE,CAAC,KAAE,CAAC,KAAE,CAAC,EAAE,GAAG;QACpB,MAAM,SAAS,CAAA,GAAA,mCAAY,EAAE;YAAC;YAAG;YAAG;SAAE;QACtC,MAAM,SAAS;YACb,MAAM;YACN,MAAM;QACR;QACA,MAAM,QAAQ;YACZ,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,OAAO;gBACL,cAAc;gBACd,cAAc;YAChB;QACF;QACA,MAAM,OAAO,CAAC,cAAc,GAAG;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC;QAClB,IAAI,QAAQ,CAAC;IACf,GACA;QAAC;KAAM;IAET,MAAM,MAAM,CAAA,GAAA,sCAAQ;IACpB,CAAA,GAAA,mDAAqB,EAAE,KAAK,MAAM;IAClC,OAAO;AACT","sources":["packages/map-interface/src/dev/tile-extent.ts"],"sourcesContent":["import { useMapConditionalStyle, useMapRef } from \"@macrostrat/mapbox-react\";\nimport { tileToGeoJSON } from \"@mapbox/tilebelt\";\nimport { useCallback } from \"react\";\n\ntype TileIndex = { x: number; y: number; z: number };\n\nexport function TileExtentLayer({\n tile,\n color = \"red\",\n}: {\n tile: TileIndex | null;\n color?: string;\n}) {\n const styleCallback = useCallback(\n (map, val: TileIndex) => {\n const style = map.getStyle();\n if (style.layers == null) return;\n style.layers = style.layers.filter((l) => l.id != \"tile-extent\");\n if (val == null) {\n return map.setStyle(style);\n }\n const { x, y, z } = val;\n const extent = tileToGeoJSON([x, y, z]);\n const source = {\n type: \"geojson\",\n data: extent,\n };\n const layer = {\n id: \"tile-extent\",\n type: \"line\",\n source: \"tile-extent\",\n paint: {\n \"line-color\": color,\n \"line-width\": 2,\n },\n };\n style.sources[\"tile-extent\"] = source;\n style.layers.push(layer);\n map.setStyle(style);\n },\n [color]\n );\n const map = useMapRef();\n useMapConditionalStyle(map, tile, styleCallback);\n return null;\n}\n"],"names":[],"version":3,"file":"tile-extent.06a4b2ed.js.map"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var $b7B0P$d3format = require("d3-format");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "fmt2", () => $bf943af2b72f182b$export$4c173b1b2f78faf7);
|
|
9
|
+
$parcel$export(module.exports, "fmt1", () => $bf943af2b72f182b$export$e54bbd2c33d17485);
|
|
10
|
+
$parcel$export(module.exports, "fmtInt", () => $bf943af2b72f182b$export$bc135f63e2f56fd4);
|
|
11
|
+
$parcel$export(module.exports, "formatValue", () => $bf943af2b72f182b$export$7c4d25c0c3217d8c);
|
|
12
|
+
|
|
13
|
+
const $bf943af2b72f182b$export$97c1b10e131a836d = (0, $b7B0P$d3format.format)(".4~f");
|
|
14
|
+
const $bf943af2b72f182b$export$b1cb0f7fb990b3ea = (0, $b7B0P$d3format.format)(".3~f");
|
|
15
|
+
const $bf943af2b72f182b$export$4c173b1b2f78faf7 = (0, $b7B0P$d3format.format)(".2~f");
|
|
16
|
+
const $bf943af2b72f182b$export$e54bbd2c33d17485 = (0, $b7B0P$d3format.format)(".1~f");
|
|
17
|
+
const $bf943af2b72f182b$export$bc135f63e2f56fd4 = (0, $b7B0P$d3format.format)(".0f");
|
|
18
|
+
function $bf943af2b72f182b$export$7c4d25c0c3217d8c(val, precision = 0) {
|
|
19
|
+
switch(precision){
|
|
20
|
+
case 4:
|
|
21
|
+
return $bf943af2b72f182b$export$97c1b10e131a836d(val);
|
|
22
|
+
case 3:
|
|
23
|
+
return $bf943af2b72f182b$export$b1cb0f7fb990b3ea(val);
|
|
24
|
+
case 2:
|
|
25
|
+
return $bf943af2b72f182b$export$4c173b1b2f78faf7(val);
|
|
26
|
+
case 1:
|
|
27
|
+
return $bf943af2b72f182b$export$e54bbd2c33d17485(val);
|
|
28
|
+
case 0:
|
|
29
|
+
return $bf943af2b72f182b$export$bc135f63e2f56fd4(val);
|
|
30
|
+
default:
|
|
31
|
+
return $bf943af2b72f182b$export$97c1b10e131a836d(val);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=utils.09cef979.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAEO,MAAM,4CAAO,CAAA,GAAA,sBAAK,EAAE;AACpB,MAAM,4CAAO,CAAA,GAAA,sBAAK,EAAE;AACpB,MAAM,4CAAO,CAAA,GAAA,sBAAK,EAAE;AACpB,MAAM,4CAAO,CAAA,GAAA,sBAAK,EAAE;AACpB,MAAM,4CAAS,CAAA,GAAA,sBAAK,EAAE;AAEtB,SAAS,0CAAY,GAAW,EAAE,YAAoB,CAAC;IAC5D,OAAQ;QACN,KAAK;YACH,OAAO,0CAAK;QACd,KAAK;YACH,OAAO,0CAAK;QACd,KAAK;YACH,OAAO,0CAAK;QACd,KAAK;YACH,OAAO,0CAAK;QACd,KAAK;YACH,OAAO,0CAAO;QAChB;YACE,OAAO,0CAAK;IAChB;AACF","sources":["packages/map-interface/src/location-info/utils.ts"],"sourcesContent":["import { format } from \"d3-format\";\n\nexport const fmt4 = format(\".4~f\");\nexport const fmt3 = format(\".3~f\");\nexport const fmt2 = format(\".2~f\");\nexport const fmt1 = format(\".1~f\");\nexport const fmtInt = format(\".0f\");\n\nexport function formatValue(val: number, precision: number = 0): string {\n switch (precision) {\n case 4:\n return fmt4(val);\n case 3:\n return fmt3(val);\n case 2:\n return fmt2(val);\n case 1:\n return fmt1(val);\n case 0:\n return fmtInt(val);\n default:\n return fmt4(val);\n }\n}\n"],"names":[],"version":3,"file":"utils.09cef979.js.map"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var $y4eOj$react = require("react");
|
|
2
|
+
var $y4eOj$mapboxgl = require("mapbox-gl");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "getMapPadding", () => $3490fc4f4bda12f7$export$bb78f9f01775eef1);
|
|
10
|
+
$parcel$export(module.exports, "useMapMarker", () => $3490fc4f4bda12f7$export$278090850f6b3a9f);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function $3490fc4f4bda12f7$var$calcMapPadding(rect, childRect) {
|
|
14
|
+
return {
|
|
15
|
+
left: Math.max(rect.left - childRect.left, 0),
|
|
16
|
+
top: Math.max(rect.top - childRect.top, 0),
|
|
17
|
+
right: Math.max(childRect.right - rect.right, 0),
|
|
18
|
+
bottom: Math.max(childRect.bottom - rect.bottom, 0)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function $3490fc4f4bda12f7$export$bb78f9f01775eef1(ref, parentRef) {
|
|
22
|
+
const rect = parentRef.current?.getBoundingClientRect();
|
|
23
|
+
const childRect = ref.current?.getBoundingClientRect();
|
|
24
|
+
if (rect == null || childRect == null) return;
|
|
25
|
+
return $3490fc4f4bda12f7$var$calcMapPadding(rect, childRect);
|
|
26
|
+
}
|
|
27
|
+
function $3490fc4f4bda12f7$export$278090850f6b3a9f(mapRef, markerRef, markerPosition) {
|
|
28
|
+
(0, $y4eOj$react.useEffect)(()=>{
|
|
29
|
+
const map = mapRef.current;
|
|
30
|
+
if (map == null) return;
|
|
31
|
+
if (markerPosition == null) {
|
|
32
|
+
markerRef.current?.remove();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const marker = markerRef.current ?? new (0, $y4eOj$mapboxgl.Marker)();
|
|
36
|
+
marker.setLngLat(markerPosition).addTo(map);
|
|
37
|
+
markerRef.current = marker;
|
|
38
|
+
return ()=>marker.remove();
|
|
39
|
+
}, [
|
|
40
|
+
mapRef.current,
|
|
41
|
+
markerPosition
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=utils.26f02633.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAGA,SAAS,qCAAe,IAAI,EAAE,SAAS;IACrC,OAAO;QACL,MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,GAAG,UAAU,IAAI,EAAE;QAC3C,KAAK,KAAK,GAAG,CAAC,KAAK,GAAG,GAAG,UAAU,GAAG,EAAE;QACxC,OAAO,KAAK,GAAG,CAAC,UAAU,KAAK,GAAG,KAAK,KAAK,EAAE;QAC9C,QAAQ,KAAK,GAAG,CAAC,UAAU,MAAM,GAAG,KAAK,MAAM,EAAE;IACnD;AACF;AAEO,SAAS,0CAAc,GAAG,EAAE,SAAS;IAC1C,MAAM,OAAO,UAAU,OAAO,EAAE;IAChC,MAAM,YAAY,IAAI,OAAO,EAAE;IAC/B,IAAI,QAAQ,QAAQ,aAAa,MAAM;IACvC,OAAO,qCAAe,MAAM;AAC9B;AAEO,SAAS,0CAAa,MAAM,EAAE,SAAS,EAAE,cAAc;IAC5D,CAAA,GAAA,sBAAQ,EAAE;QACR,MAAM,MAAM,OAAO,OAAO;QAC1B,IAAI,OAAO,MAAM;QACjB,IAAI,kBAAkB,MAAM;YAC1B,UAAU,OAAO,EAAE;YACnB;QACF;QACA,MAAM,SAAS,UAAU,OAAO,IAAI,IAAI,CAAA,GAAA,sBAAK;QAC7C,OAAO,SAAS,CAAC,gBAAgB,KAAK,CAAC;QACvC,UAAU,OAAO,GAAG;QACpB,OAAO,IAAM,OAAO,MAAM;IAC5B,GAAG;QAAC,OAAO,OAAO;QAAE;KAAe;AACrC","sources":["packages/map-interface/src/utils.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { Marker } from \"mapbox-gl\";\n\nfunction calcMapPadding(rect, childRect) {\n return {\n left: Math.max(rect.left - childRect.left, 0),\n top: Math.max(rect.top - childRect.top, 0),\n right: Math.max(childRect.right - rect.right, 0),\n bottom: Math.max(childRect.bottom - rect.bottom, 0),\n };\n}\n\nexport function getMapPadding(ref, parentRef) {\n const rect = parentRef.current?.getBoundingClientRect();\n const childRect = ref.current?.getBoundingClientRect();\n if (rect == null || childRect == null) return;\n return calcMapPadding(rect, childRect);\n}\n\nexport function useMapMarker(mapRef, markerRef, markerPosition) {\n useEffect(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (markerPosition == null) {\n markerRef.current?.remove();\n return;\n }\n const marker = markerRef.current ?? new Marker();\n marker.setLngLat(markerPosition).addTo(map);\n markerRef.current = marker;\n return () => marker.remove();\n }, [mapRef.current, markerPosition]);\n}\n"],"names":[],"version":3,"file":"utils.26f02633.js.map"}
|