@macrostrat/map-interface 1.3.2 → 1.4.1
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 +19 -0
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/{map-interface.3934d6d6.js → map-interface.10d442f4.js} +2 -2
- package/dist/cjs/{map-interface.3934d6d6.js.map → map-interface.10d442f4.js.map} +1 -1
- package/dist/cjs/{map-interface.f1eec151.js → map-interface.28d1a6b7.js} +7 -6
- package/dist/cjs/map-interface.28d1a6b7.js.map +1 -0
- package/dist/cjs/{map-interface.853e0edd.js → map-interface.3bc4f731.js} +2 -2
- package/dist/cjs/{map-interface.853e0edd.js.map → map-interface.3bc4f731.js.map} +1 -1
- package/dist/cjs/{map-interface.e7194f92.js → map-interface.7bdbe4b6.js} +59 -47
- package/dist/cjs/map-interface.7bdbe4b6.js.map +1 -0
- package/dist/cjs/{map-interface.5813e876.js → map-interface.cf6c9a68.js} +5 -5
- package/dist/cjs/{map-interface.5813e876.js.map → map-interface.cf6c9a68.js.map} +1 -1
- package/dist/cjs/{map-interface.1d19056e.js → map-interface.dcbd3874.js} +4 -2
- package/dist/cjs/map-interface.dcbd3874.js.map +1 -0
- package/dist/esm/index.d.ts +18 -38
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/{map-interface.e5349e97.js → map-interface.54ccd41f.js} +2 -2
- package/dist/esm/{map-interface.e5349e97.js.map → map-interface.54ccd41f.js.map} +1 -1
- package/dist/esm/{map-interface.25a708b1.js → map-interface.90d9023c.js} +2 -2
- package/dist/esm/{map-interface.25a708b1.js.map → map-interface.90d9023c.js.map} +1 -1
- package/dist/esm/{map-interface.9ce3d553.js → map-interface.ca1ee406.js} +61 -49
- package/dist/esm/map-interface.ca1ee406.js.map +1 -0
- package/dist/esm/{map-interface.e1493866.js → map-interface.e20a9bac.js} +4 -2
- package/dist/esm/map-interface.e20a9bac.js.map +1 -0
- package/dist/esm/{map-interface.f4e2f84e.js → map-interface.ec2278ab.js} +7 -6
- package/dist/esm/map-interface.ec2278ab.js.map +1 -0
- package/dist/esm/{map-interface.45814073.js → map-interface.f7b8bdb7.js} +5 -5
- package/dist/esm/{map-interface.45814073.js.map → map-interface.f7b8bdb7.js.map} +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/{map-interface.eb663cae.js → map-interface.33b7734a.js} +2 -2
- package/dist/node/map-interface.33b7734a.js.map +1 -0
- package/dist/node/map-interface.56b5b2ee.js +2 -0
- package/dist/node/map-interface.56b5b2ee.js.map +1 -0
- package/dist/node/{map-interface.cf540298.js → map-interface.6184dc0f.js} +2 -2
- package/dist/node/{map-interface.cf540298.js.map → map-interface.6184dc0f.js.map} +1 -1
- package/dist/node/map-interface.7aaa58c9.js +2 -0
- package/dist/node/map-interface.7aaa58c9.js.map +1 -0
- package/dist/node/{map-interface.55fa679c.js → map-interface.7e13bea8.js} +2 -2
- package/dist/node/{map-interface.55fa679c.js.map → map-interface.7e13bea8.js.map} +1 -1
- package/dist/node/map-interface.ce86a010.js +2 -0
- package/dist/node/map-interface.ce86a010.js.map +1 -0
- package/package.json +4 -4
- package/src/dev/map-page.ts +25 -19
- package/src/helpers.ts +4 -4
- package/src/location-panel/header.ts +2 -5
- 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/utils/formatting.ts +14 -0
- package/src/map-panel/utils/fossils.ts +209 -0
- package/src/map-panel/utils/index.ts +157 -0
- package/src/map-view.ts +77 -52
- package/dist/cjs/map-interface.1d19056e.js.map +0 -1
- package/dist/cjs/map-interface.e7194f92.js.map +0 -1
- package/dist/cjs/map-interface.f1eec151.js.map +0 -1
- package/dist/esm/map-interface.9ce3d553.js.map +0 -1
- package/dist/esm/map-interface.e1493866.js.map +0 -1
- package/dist/esm/map-interface.f4e2f84e.js.map +0 -1
- package/dist/node/map-interface.20c346ba.js +0 -2
- package/dist/node/map-interface.20c346ba.js.map +0 -1
- package/dist/node/map-interface.bc0fb98b.js +0 -2
- package/dist/node/map-interface.bc0fb98b.js.map +0 -1
- package/dist/node/map-interface.d9814996.js +0 -2
- package/dist/node/map-interface.d9814996.js.map +0 -1
- package/dist/node/map-interface.eb663cae.js.map +0 -1
package/src/map-view.ts
CHANGED
|
@@ -2,11 +2,11 @@ import hyper from "@macrostrat/hyper";
|
|
|
2
2
|
import {
|
|
3
3
|
useMapRef,
|
|
4
4
|
useMapDispatch,
|
|
5
|
-
useMapPosition,
|
|
6
5
|
use3DTerrain,
|
|
7
6
|
getTerrainLayerForStyle,
|
|
8
7
|
useMapStatus,
|
|
9
8
|
} from "@macrostrat/mapbox-react";
|
|
9
|
+
import React from "react";
|
|
10
10
|
import {
|
|
11
11
|
mapViewInfo,
|
|
12
12
|
MapPosition,
|
|
@@ -55,9 +55,14 @@ export interface MapViewProps extends MapboxCoreOptions {
|
|
|
55
55
|
standalone?: boolean;
|
|
56
56
|
/** Overlay styles to apply to the map: a list of mapbox style objects or fragments to
|
|
57
57
|
* overlay on top of the main map style at runtime */
|
|
58
|
-
overlayStyles?: Partial<mapboxgl.
|
|
58
|
+
overlayStyles?: Partial<mapboxgl.StyleSpecification>[];
|
|
59
59
|
/** A function to transform the map style before it is loaded */
|
|
60
|
-
transformStyle?: (
|
|
60
|
+
transformStyle?: (
|
|
61
|
+
style: mapboxgl.StyleSpecification,
|
|
62
|
+
) => mapboxgl.StyleSpecification;
|
|
63
|
+
loadingIgnoredSources?: string[];
|
|
64
|
+
id?: string;
|
|
65
|
+
className?: string;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
export interface MapboxOptionsExt extends MapboxCoreOptions {
|
|
@@ -71,7 +76,7 @@ function defaultInitializeMap(container, args: MapboxOptionsExt = {}) {
|
|
|
71
76
|
container,
|
|
72
77
|
maxZoom: 18,
|
|
73
78
|
logoPosition: "bottom-left",
|
|
74
|
-
trackResize:
|
|
79
|
+
trackResize: false,
|
|
75
80
|
antialias: true,
|
|
76
81
|
// This is a legacy option for Mapbox GL v2
|
|
77
82
|
// @ts-ignore
|
|
@@ -121,12 +126,24 @@ export function MapView(props: MapViewProps) {
|
|
|
121
126
|
standalone = false,
|
|
122
127
|
overlayStyles,
|
|
123
128
|
transformStyle,
|
|
129
|
+
trackResize = true,
|
|
130
|
+
loadingIgnoredSources = ["elevationMarker", "crossSectionEndpoints"],
|
|
131
|
+
id = "map",
|
|
132
|
+
className,
|
|
124
133
|
...rest
|
|
125
134
|
} = props;
|
|
126
135
|
if (enableTerrain) {
|
|
127
136
|
terrainSourceID ??= "mapbox-3d-dem";
|
|
128
137
|
}
|
|
129
138
|
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (id != null) {
|
|
141
|
+
console.warn(
|
|
142
|
+
"Setting a specific element ID for the map is deprecated. Please use className instead.",
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}, [id]);
|
|
146
|
+
|
|
130
147
|
const _mapboxToken = mapboxToken ?? accessToken;
|
|
131
148
|
|
|
132
149
|
if (_mapboxToken != null) {
|
|
@@ -139,26 +156,18 @@ export function MapView(props: MapViewProps) {
|
|
|
139
156
|
const parentRef = useRef<HTMLDivElement>();
|
|
140
157
|
|
|
141
158
|
const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);
|
|
142
|
-
|
|
159
|
+
|
|
160
|
+
const estMapPosition: MapPosition | null =
|
|
161
|
+
mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);
|
|
162
|
+
const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);
|
|
163
|
+
const is3DAvailable = (mapUse3D ?? false) && enableTerrain;
|
|
143
164
|
|
|
144
165
|
useEffect(() => {
|
|
145
166
|
/** Manager to update map style */
|
|
146
167
|
if (baseStyle == null) return;
|
|
147
168
|
let map = mapRef.current;
|
|
148
169
|
|
|
149
|
-
|
|
150
|
-
* immediately, before the style is loaded. This allows us to avoid a
|
|
151
|
-
* flash of the map without terrain.
|
|
152
|
-
*
|
|
153
|
-
* To do this, we need to estimate the map position before load, which
|
|
154
|
-
* doesn't always work.
|
|
155
|
-
*/
|
|
156
|
-
// We either get the map position directly from the map or from props
|
|
157
|
-
const estMapPosition: MapPosition | null =
|
|
158
|
-
map == null ? mapPosition : getMapPosition(map);
|
|
159
|
-
const { mapUse3D } = mapViewInfo(estMapPosition);
|
|
160
|
-
|
|
161
|
-
let newStyle: mapboxgl.Style = baseStyle;
|
|
170
|
+
let newStyle: mapboxgl.StyleSpecification = baseStyle;
|
|
162
171
|
|
|
163
172
|
const overlayStyles = props.overlayStyles ?? [];
|
|
164
173
|
|
|
@@ -166,7 +175,14 @@ export function MapView(props: MapViewProps) {
|
|
|
166
175
|
newStyle = mergeStyles(newStyle, ...overlayStyles);
|
|
167
176
|
}
|
|
168
177
|
|
|
169
|
-
|
|
178
|
+
/** If we can, we try to update the map style with terrain information
|
|
179
|
+
* immediately, before the style is loaded. This allows us to avoid a
|
|
180
|
+
* flash of the map without terrain.
|
|
181
|
+
*
|
|
182
|
+
* To do this, we need to estimate the map position before load, which
|
|
183
|
+
* doesn't always work.
|
|
184
|
+
*/
|
|
185
|
+
if (is3DAvailable) {
|
|
170
186
|
// We can update the style with terrain layers immediately
|
|
171
187
|
const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);
|
|
172
188
|
newStyle = mergeStyles(newStyle, terrainStyle);
|
|
@@ -177,11 +193,9 @@ export function MapView(props: MapViewProps) {
|
|
|
177
193
|
}
|
|
178
194
|
|
|
179
195
|
if (map != null) {
|
|
180
|
-
console.log("Setting style", newStyle);
|
|
181
196
|
dispatch({ type: "set-style-loaded", payload: false });
|
|
182
197
|
map.setStyle(newStyle);
|
|
183
198
|
} else {
|
|
184
|
-
console.log("Initializing map", newStyle);
|
|
185
199
|
const map = initializeMap(ref.current, {
|
|
186
200
|
style: newStyle,
|
|
187
201
|
projection,
|
|
@@ -195,26 +209,9 @@ export function MapView(props: MapViewProps) {
|
|
|
195
209
|
}
|
|
196
210
|
}, [baseStyle, overlayStyles, transformStyle]);
|
|
197
211
|
|
|
198
|
-
/** Check back every 0.1 seconds to see if the map has loaded.
|
|
199
|
-
* We do it this way because mapboxgl loading events are unreliable */
|
|
200
|
-
useEffect(() => {
|
|
201
|
-
if (isStyleLoaded) return;
|
|
202
|
-
const interval = setInterval(() => {
|
|
203
|
-
const map = mapRef.current;
|
|
204
|
-
if (map == null) return;
|
|
205
|
-
if (map.isStyleLoaded()) {
|
|
206
|
-
// Wait a tick before setting the style loaded state
|
|
207
|
-
dispatch({ type: "set-style-loaded", payload: true });
|
|
208
|
-
onStyleLoaded?.(map);
|
|
209
|
-
clearInterval(interval);
|
|
210
|
-
}
|
|
211
|
-
}, 50);
|
|
212
|
-
return () => clearInterval(interval);
|
|
213
|
-
}, [isStyleLoaded]);
|
|
214
|
-
|
|
215
212
|
useAsyncEffect(async () => {
|
|
216
213
|
/** Manager to update map style */
|
|
217
|
-
let newStyle: mapboxgl.
|
|
214
|
+
let newStyle: mapboxgl.StyleSpecification;
|
|
218
215
|
if (typeof style === "string") {
|
|
219
216
|
newStyle = await getMapboxStyle(style, {
|
|
220
217
|
access_token: mapboxgl.accessToken,
|
|
@@ -225,45 +222,73 @@ export function MapView(props: MapViewProps) {
|
|
|
225
222
|
setBaseStyle(newStyle);
|
|
226
223
|
}, [style]);
|
|
227
224
|
|
|
228
|
-
const _computedMapPosition = useMapPosition();
|
|
229
|
-
const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);
|
|
230
|
-
|
|
231
225
|
// Get map projection
|
|
232
226
|
const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
|
|
233
227
|
|
|
234
|
-
const
|
|
228
|
+
const mapClassName = classNames(
|
|
235
229
|
{
|
|
236
230
|
"is-rotated": mapIsRotated ?? false,
|
|
237
|
-
"is-3d-available":
|
|
231
|
+
"is-3d-available": is3DAvailable,
|
|
238
232
|
},
|
|
239
233
|
`${_projection}-projection`,
|
|
240
234
|
);
|
|
241
235
|
|
|
242
|
-
const parentClassName = classNames(
|
|
243
|
-
|
|
244
|
-
|
|
236
|
+
const parentClassName = classNames(
|
|
237
|
+
{
|
|
238
|
+
standalone,
|
|
239
|
+
},
|
|
240
|
+
className,
|
|
241
|
+
);
|
|
245
242
|
|
|
246
243
|
return h(
|
|
247
244
|
"div.map-view-container.main-view",
|
|
248
245
|
{ ref: parentRef, className: parentClassName },
|
|
249
246
|
[
|
|
250
|
-
h("div.mapbox-map
|
|
247
|
+
h("div.mapbox-map.map-view", { ref, className: mapClassName, id }),
|
|
251
248
|
h(MapLoadingReporter, {
|
|
252
|
-
ignoredSources:
|
|
249
|
+
ignoredSources: loadingIgnoredSources,
|
|
253
250
|
}),
|
|
251
|
+
h(StyleLoadedReporter, { onStyleLoaded }),
|
|
254
252
|
h(MapMovedReporter, { onMapMoved }),
|
|
255
|
-
|
|
253
|
+
// Subsitute for trackResize: true that allows map resizing to
|
|
254
|
+
// be tied to a specific ref component
|
|
255
|
+
h.if(trackResize)(MapResizeManager, { containerRef: ref }),
|
|
256
256
|
h(MapPaddingManager, {
|
|
257
257
|
containerRef: ref,
|
|
258
258
|
parentRef,
|
|
259
259
|
infoMarkerPosition,
|
|
260
260
|
}),
|
|
261
|
-
h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),
|
|
261
|
+
h(MapTerrainManager, { mapUse3D: is3DAvailable, terrainSourceID, style }),
|
|
262
262
|
children,
|
|
263
263
|
],
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
function StyleLoadedReporter({ onStyleLoaded = null }) {
|
|
268
|
+
/** Check back every 0.1 seconds to see if the map has loaded.
|
|
269
|
+
* We do it this way because mapboxgl loading events are unreliable */
|
|
270
|
+
const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);
|
|
271
|
+
const mapRef = useMapRef();
|
|
272
|
+
const dispatch = useMapDispatch();
|
|
273
|
+
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
if (isStyleLoaded) return;
|
|
276
|
+
const interval = setInterval(() => {
|
|
277
|
+
const map = mapRef.current;
|
|
278
|
+
if (map == null) return;
|
|
279
|
+
if (map.isStyleLoaded()) {
|
|
280
|
+
// Wait a tick before setting the style loaded state
|
|
281
|
+
dispatch({ type: "set-style-loaded", payload: true });
|
|
282
|
+
onStyleLoaded?.(map);
|
|
283
|
+
clearInterval(interval);
|
|
284
|
+
}
|
|
285
|
+
}, 50);
|
|
286
|
+
return () => clearInterval(interval);
|
|
287
|
+
}, [isStyleLoaded]);
|
|
288
|
+
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
|
|
267
292
|
export function MapTerrainManager({
|
|
268
293
|
mapUse3D,
|
|
269
294
|
terrainSourceID,
|
|
@@ -271,7 +296,7 @@ export function MapTerrainManager({
|
|
|
271
296
|
}: {
|
|
272
297
|
mapUse3D?: boolean;
|
|
273
298
|
terrainSourceID?: string;
|
|
274
|
-
style?: mapboxgl.
|
|
299
|
+
style?: mapboxgl.StyleSpecification | string;
|
|
275
300
|
}) {
|
|
276
301
|
use3DTerrain(mapUse3D, terrainSourceID);
|
|
277
302
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAE5B,SAAS,qCAAe,YAAE,QAAQ,UAAE,MAAM,gBAAE,eAAe,OAAO;IAChE,MAAM,aAAa,CAAA,GAAA,0CAAY,EAAE;IAEjC,MAAM,oBAAoB,CAAA,GAAA,uCAAS,EAAE,eAAe;IAEpD,OAAO,wBAAE,yBAAyB;QAChC,wBAAE,CAAA,GAAA,gDAAkB,GAAG;YAAE,UAAU;oBAAU;wBAAQ;QAAW,GAAG,EAAE;QACrE,wBAAE,EAAE,CAAC,qBAAqB,YAAY,MAAM,sCAAgB;YAC1D,UAAU;QACZ;KACD;AACH;AAEA,SAAS,qCAAe,YAAE,QAAQ,YAAE,QAAQ,WAAE,OAAO,EAAE,GAAG,MAAM;IAC9D,MAAM,UAAU,CAAA,GAAA,wCAAS;IAEzB,IAAI,UAAU,CAAC,WAAW,CAAC;IAC3B,IAAI,YAAY,MACd,WAAW,CAAC,IAAI,EAAE,UAAU;IAE9B,WAAW;IAEX,OAAO,wBACL,CAAA,GAAA,6BAAK,GACL;QACE,WAAW;QACX,WAAW,wBAAE,CAAA,GAAA,2BAAG,GAAG;YAAE,MAAM;YAAQ,MAAM;QAAG;QAC5C,SAAS;QACT,OAAO;QACP;YACE,UAAU,SAAS,CAAC,SAAS,CAAC,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,CACtD;gBACE,SAAS,KAAK;6BACZ;oBACA,QAAQ;oBACR,MAAM;oBACN,SAAS;gBACX;gBACA;YACF,GACA;gBACE,SAAS,KAAK;oBACZ,SAAS;oBACT,QAAQ;oBACR,MAAM;oBACN,SAAS;gBACX;YACF;QAEJ;QACA,GAAG,IAAI;IACT,GACA,YAAY;AAEhB;AAcO,SAAS,0CAAiB,KAA4B;IAC3D,MAAM,WACJ,OAAO,YACP,QAAQ,UACR,MAAM,QACN,OAAO,cACP,SAAS,0BACT,sBAAsB,eACtB,cAAc,iBACd,QAAQ,aACR,SAAS,EACV,GAAG;IAEJ,IAAI,aAAa;IACjB,IAAI,UAAU,QAAQ,YAAY,MAChC,aAAa,wBAAE,sCAAgB;kBAC7B;gBACA;QACA,cAAc;IAChB;IAGF,OAAO,wBACL,gCACA;QACE,WAAW,CAAA,GAAA,2CAAS,EAAE,WAAW;YAAE,gBAAgB;QAAY;IACjE,GACA;QACE;QACA;QACA,wBAAE;QACF,wBAAE,EAAE,CAAC,YAAY,MAAM,CAAA,GAAA,sCAAW,GAAG;sBACnC;kBACA;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,aAAa,MAAM,CAAA,GAAA,mCAAQ,GAAG;uBACjC;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,WAAW,MAAM,CAAA,GAAA,6BAAK,GAAG;YAC5B,SAAS;YACT,MAAM;YACN,SAAS;QACX;KACD;AAEL","sources":["packages/map-interface/src/location-panel/header.ts"],"sourcesContent":["import { Icon, Button } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useToaster } from \"@macrostrat/ui-components\";\nimport { LngLatCoords, Elevation } from \"../location-info\";\nimport {\n LocationFocusButton,\n useFocusState,\n isCentered,\n} from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\nimport type { ReactNode } from \"react\";\nimport type { LngLatBounds, LngLatLike } from \"mapbox-gl\";\n\nconst h = hyper.styled(styles);\n\nfunction PositionButton({ position, bounds, showCopyLink = false }) {\n const focusState = useFocusState(position);\n\n const copyLinkIsVisible = isCentered(focusState) && showCopyLink;\n\n return h(\"div.position-controls\", [\n h(LocationFocusButton, { location: position, bounds, focusState }, []),\n h.if(copyLinkIsVisible && position != null)(CopyLinkButton, {\n itemName: \"position\",\n }),\n ]);\n}\n\nfunction CopyLinkButton({ itemName, children, onClick, ...rest }) {\n const toaster = useToaster();\n\n let message = `Copied link`;\n if (itemName != null) {\n message += ` to ${itemName}`;\n }\n message += \"!\";\n\n return h(\n Button,\n {\n className: \"copy-link-button\",\n rightIcon: h(Icon, { icon: \"link\", size: 12 }),\n minimal: true,\n small: true,\n onClick() {\n navigator.clipboard.writeText(window.location.href).then(\n () => {\n toaster?.show({\n message,\n intent: \"success\",\n icon: \"clipboard\",\n timeout: 1000,\n });\n onClick?.();\n },\n () => {\n toaster?.show({\n message: \"Failed to copy link\",\n intent: \"danger\",\n icon: \"error\",\n timeout: 1000,\n });\n },\n );\n },\n ...rest,\n },\n children ?? \"Copy link\",\n );\n}\n\nexport interface InfoDrawerHeaderProps {\n onClose?: () => void;\n position?: LngLatLike;\n zoom?: number;\n elevation?: number;\n showCopyPositionButton?: boolean;\n bounds?: LngLatBounds;\n fixedHeight?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport function InfoDrawerHeader(props: InfoDrawerHeaderProps) {\n const {\n onClose,\n position,\n bounds,\n zoom = 7,\n elevation,\n showCopyPositionButton,\n fixedHeight = false,\n children,\n className,\n } = props;\n\n let leftButton = null;\n if (bounds != null || position != null) {\n leftButton = h(PositionButton, {\n position,\n bounds,\n showCopyLink: showCopyPositionButton,\n });\n }\n\n return h(\n \"header.location-panel-header\",\n {\n className: classNames(className, { \"fixed-height\": fixedHeight }),\n },\n [\n leftButton,\n children,\n h(\"div.spacer\"),\n h.if(position != null)(LngLatCoords, {\n position,\n zoom,\n className: \"infodrawer-header-item\",\n }),\n h.if(elevation != null)(Elevation, {\n elevation,\n className: \"infodrawer-header-item\",\n }),\n h.if(onClose != null)(Button, {\n minimal: true,\n icon: \"cross\",\n onClick: onClose,\n }),\n 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,GAAA,0CAAe,GAAG;YAAE,cAAc;QAAI;QACxC,wBAAE,CAAA,GAAA,2CAAgB,GAAG;YACnB,cAAc;uBACd;gCACA;QACF;QACA,wBAAE,2CAAmB;sBAAE;6BAAU;mBAAiB;QAAM;QACxD;KACD;AAEL;AAEO,SAAS,0CAAkB,YAChC,QAAQ,mBACR,eAAe,SACf,KAAK,EAKN;IACC,CAAA,GAAA,yCAAW,EAAE,UAAU;IAEvB,OAAO;AACT","sources":["packages/map-interface/src/map-view.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-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.Style>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;\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: true,\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 ...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 const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\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 // We either get the map position directly from the map or from props\n const estMapPosition: MapPosition | null =\n map == null ? mapPosition : getMapPosition(map);\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n let newStyle: mapboxgl.Style = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n if (mapUse3D) {\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 console.log(\"Setting style\", newStyle);\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\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 /** 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 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 useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.Style;\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 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 const parentClassName = classNames({\n standalone,\n });\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\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, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.Style | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.e7194f92.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAA0B;;;;;;;;;;;;;;;AAqBnB,MAAM,4CAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAE5B,SAAS,0CAAe,SAC7B,QAAQ,gCACR,gBAAgB,wBAChB,mBAAmB,mBACnB,cAAc,mBACd,cAAc,oBACd,eAAe,gBACf,WAAW,gBACX,W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C,QAAQ,IAAI,CAAC;IAEb,OAAO,0CAAE,2CAAgB;QACvB,GAAG,IAAI;QACP,UAAU;YAAC;YAAU;SAAS;IAChC;AACF;AAGO,MAAM,4CAAa","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, useBasicMapStyle } 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 const basicStyle = useBasicMapStyle({ styleType });\n style ??= basicStyle;\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-interface.f1eec151.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,wEAAK;AAmC5B,SAAS,2CAAqB,SAAS,EAAE,OAAyB,CAAC,CAAC;IAClE,MAAM,eAAE,WAAW,EAAE,GAAG,MAAM,GAAG;IAEjC,MAAM,MAAM,IAAI,CAAA,GAAA,eAAO,EAAE,GAAG,CAAC;mBAC3B;QACA,SAAS;QACT,cAAc;QACd,aAAa;QACb,WAAW;QACX,2CAA2C;QAC3C,aAAa;QACb,oBAAoB;QACpB,GAAG,IAAI;IACT;IAEA,IAAI,eAAe;IACnB,IAAI,gBAAgB,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM,IAAI,MAChE,oEAAoE;IACpE,eAAe;IAGjB,2BAA2B;IAC3B,IAAI,gBAAgB,MAClB,CAAA,GAAA,qBAAa,EAAE,KAAK;IAGtB,OAAO;AACT;AAEA,MAAM,2CAAkC;IACtC,QAAQ;QACN,KAAK;QACL,KAAK;QACL,UAAU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AO,EAAE,iBAAiB,QAAQ;IAE7D,MAAM,YAAY,CAAA,GAAA,iBAAS,EACzB;QACE,cAAc,gBAAgB;QAC9B,mBAAmB,YAAY;IACjC,GACA,GAAG,YAAY,WAAW,CAAC;IAG7B,MAAM,kBAAkB,CAAA,GAAA,iBAAS,EAAE;oBACjC;IACF;IAEA,OAAO,wBACL,oCACA;QAAE,KAAK;QAAW,WAAW;IAAgB,GAC7C;QACE,wBAAE,sBAAsB;iBAAE;uBAAK;QAAU;QACzC,wBAAE,CAAA,GAAA,yCAAiB,GAAG;YACpB,gBAAgB;gBAAC;gBAAmB;aAAwB;QAC9D;QACA,wBAAE,CAAA,GAAA,yCAAe,GAAG;wBAAE;QAAW;QACjC,wBAAE,CAAA,GAAA,yCAAe,GAAG;YAAE,cAAc;QAAI;QACxC,wBAAE,CAAA,GAAA,yCAAgB,GAAG;YACnB,cAAc;uBACd;gCACA;QACF;QACA,wBAAE,2CAAmB;sBAAE;6BAAU;mBAAiB;QAAM;QACxD;KACD;AAEL;AAEO,SAAS,0CAAkB,YAChC,QAAQ,mBACR,eAAe,SACf,KAAK,EAKN;IACC,CAAA,GAAA,mBAAW,EAAE,UAAU;IAEvB,OAAO;AACT","sources":["packages/map-interface/src/map-view.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-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.Style>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;\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: true,\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 ...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 const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\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 // We either get the map position directly from the map or from props\n const estMapPosition: MapPosition | null =\n map == null ? mapPosition : getMapPosition(map);\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n let newStyle: mapboxgl.Style = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n if (mapUse3D) {\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 console.log(\"Setting style\", newStyle);\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\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 /** 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 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 useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.Style;\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 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 const parentClassName = classNames({\n standalone,\n });\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\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, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.Style | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.9ce3d553.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,wEAAK;AAE5B,SAAS,qCAAe,YAAE,QAAQ,UAAE,MAAM,gBAAE,eAAe,OAAO;IAChE,MAAM,aAAa,CAAA,GAAA,oBAAY,EAAE;IAEjC,MAAM,oBAAoB,CAAA,GAAA,iBAAS,EAAE,eAAe;IAEpD,OAAO,wBAAE,yBAAyB;QAChC,wBAAE,CAAA,GAAA,0BAAkB,GAAG;YAAE,UAAU;oBAAU;wBAAQ;QAAW,GAAG,EAAE;QACrE,wBAAE,EAAE,CAAC,qBAAqB,YAAY,MAAM,sCAAgB;YAC1D,UAAU;QACZ;KACD;AACH;AAEA,SAAS,qCAAe,YAAE,QAAQ,YAAE,QAAQ,WAAE,OAAO,EAAE,GAAG,MAAM;IAC9D,MAAM,UAAU,CAAA,GAAA,iBAAS;IAEzB,IAAI,UAAU,CAAC,WAAW,CAAC;IAC3B,IAAI,YAAY,MACd,WAAW,CAAC,IAAI,EAAE,UAAU;IAE9B,WAAW;IAEX,OAAO,wBACL,CAAA,GAAA,aAAK,GACL;QACE,WAAW;QACX,WAAW,wBAAE,CAAA,GAAA,WAAG,GAAG;YAAE,MAAM;YAAQ,MAAM;QAAG;QAC5C,SAAS;QACT,OAAO;QACP;YACE,UAAU,SAAS,CAAC,SAAS,CAAC,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,CACtD;gBACE,SAAS,KAAK;6BACZ;oBACA,QAAQ;oBACR,MAAM;oBACN,SAAS;gBACX;gBACA;YACF,GACA;gBACE,SAAS,KAAK;oBACZ,SAAS;oBACT,QAAQ;oBACR,MAAM;oBACN,SAAS;gBACX;YACF;QAEJ;QACA,GAAG,IAAI;IACT,GACA,YAAY;AAEhB;AAcO,SAAS,0CAAiB,KAA4B;IAC3D,MAAM,WACJ,OAAO,YACP,QAAQ,UACR,MAAM,QACN,OAAO,cACP,SAAS,0BACT,sBAAsB,eACtB,cAAc,iBACd,QAAQ,aACR,SAAS,EACV,GAAG;IAEJ,IAAI,aAAa;IACjB,IAAI,UAAU,QAAQ,YAAY,MAChC,aAAa,wBAAE,sCAAgB;kBAC7B;gBACA;QACA,cAAc;IAChB;IAGF,OAAO,wBACL,gCACA;QACE,WAAW,CAAA,GAAA,iBAAS,EAAE,WAAW;YAAE,gBAAgB;QAAY;IACjE,GACA;QACE;QACA;QACA,wBAAE;QACF,wBAAE,EAAE,CAAC,YAAY,MAAM,CAAA,GAAA,yCAAW,GAAG;sBACnC;kBACA;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,aAAa,MAAM,CAAA,GAAA,yCAAQ,GAAG;uBACjC;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,WAAW,MAAM,CAAA,GAAA,aAAK,GAAG;YAC5B,SAAS;YACT,MAAM;YACN,SAAS;QACX;KACD;AAEL","sources":["packages/map-interface/src/location-panel/header.ts"],"sourcesContent":["import { Icon, Button } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useToaster } from \"@macrostrat/ui-components\";\nimport { LngLatCoords, Elevation } from \"../location-info\";\nimport {\n LocationFocusButton,\n useFocusState,\n isCentered,\n} from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\nimport type { ReactNode } from \"react\";\nimport type { LngLatBounds, LngLatLike } from \"mapbox-gl\";\n\nconst h = hyper.styled(styles);\n\nfunction PositionButton({ position, bounds, showCopyLink = false }) {\n const focusState = useFocusState(position);\n\n const copyLinkIsVisible = isCentered(focusState) && showCopyLink;\n\n return h(\"div.position-controls\", [\n h(LocationFocusButton, { location: position, bounds, focusState }, []),\n h.if(copyLinkIsVisible && position != null)(CopyLinkButton, {\n itemName: \"position\",\n }),\n ]);\n}\n\nfunction CopyLinkButton({ itemName, children, onClick, ...rest }) {\n const toaster = useToaster();\n\n let message = `Copied link`;\n if (itemName != null) {\n message += ` to ${itemName}`;\n }\n message += \"!\";\n\n return h(\n Button,\n {\n className: \"copy-link-button\",\n rightIcon: h(Icon, { icon: \"link\", size: 12 }),\n minimal: true,\n small: true,\n onClick() {\n navigator.clipboard.writeText(window.location.href).then(\n () => {\n toaster?.show({\n message,\n intent: \"success\",\n icon: \"clipboard\",\n timeout: 1000,\n });\n onClick?.();\n },\n () => {\n toaster?.show({\n message: \"Failed to copy link\",\n intent: \"danger\",\n icon: \"error\",\n timeout: 1000,\n });\n },\n );\n },\n ...rest,\n },\n children ?? \"Copy link\",\n );\n}\n\nexport interface InfoDrawerHeaderProps {\n onClose?: () => void;\n position?: LngLatLike;\n zoom?: number;\n elevation?: number;\n showCopyPositionButton?: boolean;\n bounds?: LngLatBounds;\n fixedHeight?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport function InfoDrawerHeader(props: InfoDrawerHeaderProps) {\n const {\n onClose,\n position,\n bounds,\n zoom = 7,\n elevation,\n showCopyPositionButton,\n fixedHeight = false,\n children,\n className,\n } = props;\n\n let leftButton = null;\n if (bounds != null || position != null) {\n leftButton = h(PositionButton, {\n position,\n bounds,\n showCopyLink: showCopyPositionButton,\n });\n }\n\n return h(\n \"header.location-panel-header\",\n {\n className: classNames(className, { \"fixed-height\": fixedHeight }),\n },\n [\n leftButton,\n children,\n h(\"div.spacer\"),\n h.if(position != null)(LngLatCoords, {\n position,\n zoom,\n className: \"infodrawer-header-item\",\n }),\n h.if(elevation != null)(Elevation, {\n elevation,\n className: \"infodrawer-header-item\",\n }),\n h.if(onClose != null)(Button, {\n minimal: true,\n icon: \"cross\",\n onClick: onClose,\n }),\n ],\n );\n}\n"],"names":[],"version":3,"file":"map-interface.e1493866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kB;YAClB,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,yCAAQ,GAAG;YACX,UAAU;YACV,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,yCAAc,GAAG;kBAAE;YAAM,OAAO,YAAY,UAAU;QAAQ;QAChE;KACD;AAGP;AAEA,SAAS,mCAAa,KAAK;IACzB,MAAM,YAAE,QAAQ,YAAE,QAAQ,EAAE,GAAG,MAAM,GAAG;IACxC,6CAA6C,GAC7C,wCAAwC;IACxC,QAAQ,IAAI,CAAC;IAEb,OAAO,0CAAE,2CAAgB;QACvB,GAAG,IAAI;QACP,UAAU;YAAC;YAAU;SAAS;IAChC;AACF;AAGO,MAAM,4CAAa","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, useBasicMapStyle } 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 const basicStyle = useBasicMapStyle({ styleType });\n style ??= basicStyle;\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-interface.f4e2f84e.js.map"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
require("./map-interface.3ea55e0c.js"),require("./map-interface.eb663cae.js"),require("./map-interface.713361a4.js");var $iE1eH$macrostrathyper=require("@macrostrat/hyper"),$iE1eH$macrostratmapboxreact=require("@macrostrat/mapbox-react"),$iE1eH$macrostratmapboxutils=require("@macrostrat/mapbox-utils"),$iE1eH$classnames=require("classnames"),$iE1eH$mapboxgl=require("mapbox-gl"),$iE1eH$react=require("react");require("mapbox-gl/dist/mapbox-gl.css");var $iE1eH$macrostratuicomponents=require("@macrostrat/ui-components");function $parcel$interopDefault(e){return e&&e.__esModule?e.default:e}function $parcel$export(e,a,r,t){Object.defineProperty(e,a,{get:r,set:t,enumerable:!0,configurable:!0})}var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequirea149;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var a=$parcel$inits[e];delete $parcel$inits[e];var r={id:e,exports:{}};return $parcel$modules[e]=r,a.call(r.exports,r,r.exports),r.exports}var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}).register=function(e,a){$parcel$inits[e]=a},$parcel$global.parcelRequirea149=parcelRequire);var parcelRegister=parcelRequire.register;$parcel$export(module.exports,"MapView",()=>$8c5236898eee97dc$export$ab1e7a67d6ec5ad8),$parcel$export(module.exports,"MapTerrainManager",()=>$8c5236898eee97dc$export$cee395a8a2a00b29);var $6ULxP=parcelRequire("6ULxP"),$7CmOU=parcelRequire("7CmOU"),$R3my3=parcelRequire("R3my3");let $8c5236898eee97dc$var$h=$parcel$interopDefault($iE1eH$macrostrathyper).styled($parcel$interopDefault($6ULxP));function $8c5236898eee97dc$var$defaultInitializeMap(e,a={}){let{mapPosition:r,...t}=a,o=new($parcel$interopDefault($iE1eH$mapboxgl)).Map({container:e,maxZoom:18,logoPosition:"bottom-left",trackResize:!0,antialias:!0,optimizeForTerrain:!0,...t}),i=r;return null==i&&null==t.center&&null==t.bounds&&(i=$8c5236898eee97dc$var$defaultMapPosition),null!=i&&(0,$iE1eH$macrostratmapboxutils.setMapPosition)(o,i),o}let $8c5236898eee97dc$var$defaultMapPosition={camera:{lat:34,lng:-120,altitude:3e5}};function $8c5236898eee97dc$export$ab1e7a67d6ec5ad8(e){let{terrainSourceID:a}=e,{enableTerrain:r=!0,style:t,mapPosition:o,initializeMap:i=$8c5236898eee97dc$var$defaultInitializeMap,children:l,mapboxToken:c,accessToken:$,infoMarkerPosition:n,transformRequest:s,projection:p,onMapLoaded:u=null,onStyleLoaded:m=null,onMapMoved:d=null,standalone:f=!1,overlayStyles:x,transformStyle:b,...E}=e;r&&(a??(a="mapbox-3d-dem"));let g=c??$;null!=g&&($parcel$interopDefault($iE1eH$mapboxgl).accessToken=g);let y=(0,$iE1eH$macrostratmapboxreact.useMapDispatch)(),H=(0,$iE1eH$macrostratmapboxreact.useMapRef)(),v=(0,$iE1eH$react.useRef)(),M=(0,$iE1eH$react.useRef)(),[R,q]=(0,$iE1eH$react.useState)(null),S=(0,$iE1eH$macrostratmapboxreact.useMapStatus)(e=>e.isStyleLoaded);(0,$iE1eH$react.useEffect)(()=>{if(null==R)return;let r=H.current,t=null==r?o:(0,$iE1eH$macrostratmapboxutils.getMapPosition)(r),{mapUse3D:l}=(0,$iE1eH$macrostratmapboxutils.mapViewInfo)(t),c=R,$=e.overlayStyles??[];if($.length>0&&(c=(0,$iE1eH$macrostratmapboxutils.mergeStyles)(c,...$)),l){let e=(0,$iE1eH$macrostratmapboxreact.getTerrainLayerForStyle)(c,a);c=(0,$iE1eH$macrostratmapboxutils.mergeStyles)(c,e)}if(null!=b&&(c=b(c)),null!=r)console.log("Setting style",c),y({type:"set-style-loaded",payload:!1}),r.setStyle(c);else{console.log("Initializing map",c);let e=i(v.current,{style:c,projection:p,mapPosition:o,transformRequest:s,...E});y({type:"set-map",payload:e}),e.setPadding((0,$R3my3.getMapPadding)(v,M),{animate:!1}),u?.(e)}},[R,x,b]),(0,$iE1eH$react.useEffect)(()=>{if(S)return;let e=setInterval(()=>{let a=H.current;null!=a&&a.isStyleLoaded()&&(y({type:"set-style-loaded",payload:!0}),m?.(a),clearInterval(e))},50);return()=>clearInterval(e)},[S]),(0,$iE1eH$macrostratuicomponents.useAsyncEffect)(async()=>{let e;q("string"==typeof t?await (0,$iE1eH$macrostratmapboxutils.getMapboxStyle)(t,{access_token:$parcel$interopDefault($iE1eH$mapboxgl).accessToken}):t)},[t]);let D=(0,$iE1eH$macrostratmapboxreact.useMapPosition)(),{mapUse3D:P,mapIsRotated:h}=(0,$iE1eH$macrostratmapboxutils.mapViewInfo)(D),U=H.current?.getProjection()?.name??"mercator",I=$parcel$interopDefault($iE1eH$classnames)({"is-rotated":h??!1,"is-3d-available":P??!1},`${U}-projection`);return $8c5236898eee97dc$var$h("div.map-view-container.main-view",{ref:M,className:$parcel$interopDefault($iE1eH$classnames)({standalone:f})},[$8c5236898eee97dc$var$h("div.mapbox-map#map",{ref:v,className:I}),$8c5236898eee97dc$var$h($7CmOU.MapLoadingReporter,{ignoredSources:["elevationMarker","crossSectionEndpoints"]}),$8c5236898eee97dc$var$h($7CmOU.MapMovedReporter,{onMapMoved:d}),$8c5236898eee97dc$var$h($7CmOU.MapResizeManager,{containerRef:v}),$8c5236898eee97dc$var$h($7CmOU.MapPaddingManager,{containerRef:v,parentRef:M,infoMarkerPosition:n}),$8c5236898eee97dc$var$h($8c5236898eee97dc$export$cee395a8a2a00b29,{mapUse3D:P,terrainSourceID:a,style:t}),l])}function $8c5236898eee97dc$export$cee395a8a2a00b29({mapUse3D:e,terrainSourceID:a,style:r}){return(0,$iE1eH$macrostratmapboxreact.use3DTerrain)(e,a),null}
|
|
2
|
-
//# sourceMappingURL=map-interface.20c346ba.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,Q,gD,Q,gD,Q,gD,I,uB,Q,qB,6B,Q,4B,6B,Q,4B,kB,Q,c,gB,Q,a,a,Q,S,Q,gC,I,8B,Q,6B,S,uB,C,E,O,G,E,U,C,E,O,C,C,C,S,e,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,I,e,W,gB,C,E,c,C,E,c,e,iB,A,O,gB,A,C,c,S,C,E,G,K,gB,O,e,C,E,C,O,C,G,K,c,C,I,E,a,C,E,A,Q,a,C,E,C,I,E,C,G,E,Q,C,C,E,O,e,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,a,C,E,C,C,E,e,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I+C,EAC7C,CACE,wBAAE,qBAAsB,CAAE,IAAA,EAAK,UAAA,CAAU,GACzC,wBAAE,OAAA,kBAAiB,CAAG,CACpB,eAAgB,CAAC,kBAAmB,wBAAwB,AAC9D,GACA,wBAAE,OAAA,gBAAe,CAAG,CAAE,WAAA,CAAW,GACjC,wBAAE,OAAA,gBAAe,CAAG,CAAE,aAAc,CAAI,GACxC,wBAAE,OAAA,iBAAgB,CAAG,CACnB,aAAc,EACd,UAAA,EACA,mBAAA,CACF,GACA,wBAAE,0CAAmB,CAAE,SAAA,EAAU,gBAAA,EAAiB,MAAA,CAAM,GACxD,EACD,CAEL,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.eb663cae.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: true,\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, ...rest } = props;\n if (enableTerrain) terrainSourceID ?? (terrainSourceID = \"mapbox-3d-dem\");\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 isStyleLoaded = (0, $iE1eH$macrostratmapboxreact.useMapStatus)((state)=>state.isStyleLoaded);\n (0, $iE1eH$react.useEffect)(()=>{\n /** Manager to update map style */ if (baseStyle == null) return;\n let map = mapRef.current;\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 */ // We either get the map position directly from the map or from props\n const estMapPosition = map == null ? mapPosition : (0, $iE1eH$macrostratmapboxutils.getMapPosition)(map);\n const { mapUse3D: mapUse3D } = (0, $iE1eH$macrostratmapboxutils.mapViewInfo)(estMapPosition);\n let newStyle = baseStyle;\n const overlayStyles = props.overlayStyles ?? [];\n if (overlayStyles.length > 0) newStyle = (0, $iE1eH$macrostratmapboxutils.mergeStyles)(newStyle, ...overlayStyles);\n if (mapUse3D) {\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 console.log(\"Setting style\", newStyle);\n dispatch({\n type: \"set-style-loaded\",\n payload: false\n });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\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 /** 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 */ (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 (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 const _computedMapPosition = (0, $iE1eH$macrostratmapboxreact.useMapPosition)();\n const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $iE1eH$macrostratmapboxutils.mapViewInfo)(_computedMapPosition);\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n const className = (0, ($parcel$interopDefault($iE1eH$classnames)))({\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false\n }, `${_projection}-projection`);\n const parentClassName = (0, ($parcel$interopDefault($iE1eH$classnames)))({\n standalone: standalone\n });\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\", {\n ref: ref,\n className: className\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapLoadingReporter), {\n ignoredSources: [\n \"elevationMarker\",\n \"crossSectionEndpoints\"\n ]\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapMovedReporter), {\n onMapMoved: onMapMoved\n }),\n $8c5236898eee97dc$var$h((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: mapUse3D,\n terrainSourceID: terrainSourceID,\n style: style\n }),\n children\n ]);\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.20c346ba.js.map\n","import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-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.Style>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;\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: true,\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 ...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 const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\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 // We either get the map position directly from the map or from props\n const estMapPosition: MapPosition | null =\n map == null ? mapPosition : getMapPosition(map);\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n let newStyle: mapboxgl.Style = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n if (mapUse3D) {\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 console.log(\"Setting style\", newStyle);\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\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 /** 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 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 useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.Style;\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 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 const parentClassName = classNames({\n standalone,\n });\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\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, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.Style | 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","_mapboxToken","dispatch","useMapDispatch","mapRef","useMapRef","ref","useRef","parentRef","baseStyle","setBaseStyle","useState","isStyleLoaded","useMapStatus","state","useEffect","current","estMapPosition","getMapPosition","mapUse3D","mapViewInfo","newStyle","length","mergeStyles","terrainStyle","getTerrainLayerForStyle","console","log","type","payload","setStyle","setPadding","getMapPadding","animate","interval","setInterval","clearInterval","useAsyncEffect","getMapboxStyle","access_token","_computedMapPosition","useMapPosition","mapIsRotated","_projection","getProjection","name","className","MapLoadingReporter","ignoredSources","MapMovedReporter","MapResizeManager","containerRef","MapPaddingManager","use3DTerrain"],"version":3,"file":"map-interface.20c346ba.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
require("./map-interface.1a5eecac.js"),require("./map-interface.d92b296e.js");var $9HnAS$blueprintjscore=require("@blueprintjs/core"),$9HnAS$macrostrathyper=require("@macrostrat/hyper"),$9HnAS$macrostratuicomponents=require("@macrostrat/ui-components"),$9HnAS$macrostratmapboxreact=require("@macrostrat/mapbox-react"),$9HnAS$classnames=require("classnames");function $parcel$interopDefault(e){return e&&e.__esModule?e.default:e}var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequirea149;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var a=$parcel$inits[e];delete $parcel$inits[e];var r={id:e,exports:{}};return $parcel$modules[e]=r,a.call(r.exports,r,r.exports),r.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,a){$parcel$inits[e]=a},$parcel$global.parcelRequirea149=parcelRequire);var parcelRegister=parcelRequire.register,$2UJTP=parcelRequire("2UJTP"),$66CcX=parcelRequire("66CcX");let $1a913554a5c0869b$var$h=$parcel$interopDefault($9HnAS$macrostrathyper).styled($parcel$interopDefault($2UJTP));function $1a913554a5c0869b$var$PositionButton({position:e,bounds:a,showCopyLink:r=!1}){let o=(0,$9HnAS$macrostratmapboxreact.useFocusState)(e),t=(0,$9HnAS$macrostratmapboxreact.isCentered)(o)&&r;return $1a913554a5c0869b$var$h("div.position-controls",[$1a913554a5c0869b$var$h($9HnAS$macrostratmapboxreact.LocationFocusButton,{location:e,bounds:a,focusState:o},[]),$1a913554a5c0869b$var$h.if(t&&null!=e)($1a913554a5c0869b$var$CopyLinkButton,{itemName:"position"})])}function $1a913554a5c0869b$var$CopyLinkButton({itemName:e,children:a,onClick:r,...o}){let t=(0,$9HnAS$macrostratuicomponents.useToaster)(),n="Copied link";return null!=e&&(n+=` to ${e}`),n+="!",$1a913554a5c0869b$var$h($9HnAS$blueprintjscore.Button,{className:"copy-link-button",rightIcon:$1a913554a5c0869b$var$h($9HnAS$blueprintjscore.Icon,{icon:"link",size:12}),minimal:!0,small:!0,onClick(){navigator.clipboard.writeText(window.location.href).then(()=>{t?.show({message:n,intent:"success",icon:"clipboard",timeout:1e3}),r?.()},()=>{t?.show({message:"Failed to copy link",intent:"danger",icon:"error",timeout:1e3})})},...o},a??"Copy link")}function $1a913554a5c0869b$export$e9ff14c4822c2e8c(e){let{onClose:a,position:r,bounds:o,zoom:t=7,elevation:n,showCopyPositionButton:i,fixedHeight:c=!1,children:$,className:l}=e,s=null;return(null!=o||null!=r)&&(s=$1a913554a5c0869b$var$h($1a913554a5c0869b$var$PositionButton,{position:r,bounds:o,showCopyLink:i})),$1a913554a5c0869b$var$h("header.location-panel-header",{className:$parcel$interopDefault($9HnAS$classnames)(l,{"fixed-height":c})},[s,$,$1a913554a5c0869b$var$h("div.spacer"),$1a913554a5c0869b$var$h.if(null!=r)($66CcX.LngLatCoords,{position:r,zoom:t,className:"infodrawer-header-item"}),$1a913554a5c0869b$var$h.if(null!=n)($66CcX.Elevation,{elevation:n,className:"infodrawer-header-item"}),$1a913554a5c0869b$var$h.if(null!=a)($9HnAS$blueprintjscore.Button,{minimal:!0,icon:"cross",onClick:a})])}
|
|
2
|
-
//# sourceMappingURL=map-interface.bc0fb98b.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,Q,gD,Q,gD,I,uB,Q,qB,uB,Q,qB,8B,Q,6B,6B,Q,4B,kB,Q,c,S,uB,C,E,O,G,E,U,C,E,O,C,C,C,I,e,W,gB,C,E,c,C,E,c,e,iB,A,O,gB,A,C,c,S,C,E,G,K,gB,O,e,C,E,C,O,C,G,K,c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M,YACN,QAAS,GACX,GACA,KACF,EACA,KACE,GAAS,KAAK,CACZ,QAAS,sBACT,OAAQ,SACR,KAAM,QACN,QAAS,GACX,EACF,EAEJ,EACA,GAAG,CAAI,AACT,EACA,GAAY,YAEhB,CAcO,SAAS,0CAAiB,CAA4B,EAC3D,GAAM,CAAA,QACJ,CAAO,CAAA,SACP,CAAQ,CAAA,OACR,CAAM,CAAA,KACN,EAAO,CAAA,CAAA,UACP,CAAS,CAAA,uBACT,CAAsB,CAAA,YACtB,EAAc,CAAA,CAAA,CAAA,SACd,CAAQ,CAAA,UACR,CAAS,CACV,CAAG,EAEA,EAAa,KASjB,MARI,CAAA,AAAU,MAAV,GAAkB,AAAY,MAAZ,CAAY,GAChC,CAAA,EAAa,wBAAE,qCAAgB,CAC7B,SAAA,EACA,OAAA,EACA,aAAc,CAChB,EAAA,EAGK,wBACL,+BACA,CACE,UAAW,AAAA,uBAAA,mBAAW,EAAW,CAAE,eAAgB,CAAY,EACjE,EACA,CACE,EACA,EACA,wBAAE,cACF,wBAAE,EAAE,CAAC,AAAY,MAAZ,GAAkB,OAAA,YAAW,CAAG,CACnC,SAAA,EACA,KAAA,EACA,UAAW,wBACb,GACA,wBAAE,EAAE,CAAC,AAAa,MAAb,GAAmB,OAAA,SAAQ,CAAG,CACjC,UAAA,EACA,UAAW,wBACb,GACA,wBAAE,EAAE,CAAC,AAAW,MAAX,GAAiB,uBAAA,MAAK,CAAG,CAC5B,QAAS,CAAA,EACT,KAAM,QACN,QAAS,CACX,GACD,CAEL","sources":["<anon>","packages/map-interface/src/location-panel/header.ts"],"sourcesContent":["require(\"./map-interface.1a5eecac.js\");\nrequire(\"./map-interface.d92b296e.js\");\nvar $9HnAS$blueprintjscore = require(\"@blueprintjs/core\");\nvar $9HnAS$macrostrathyper = require(\"@macrostrat/hyper\");\nvar $9HnAS$macrostratuicomponents = require(\"@macrostrat/ui-components\");\nvar $9HnAS$macrostratmapboxreact = require(\"@macrostrat/mapbox-react\");\nvar $9HnAS$classnames = require(\"classnames\");\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\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\n\nvar $2UJTP = parcelRequire(\"2UJTP\");\n\n\nvar $66CcX = parcelRequire(\"66CcX\");\n\n\nconst $1a913554a5c0869b$var$h = (0, ($parcel$interopDefault($9HnAS$macrostrathyper))).styled((0, (/*@__PURE__*/$parcel$interopDefault($2UJTP))));\nfunction $1a913554a5c0869b$var$PositionButton({ position: position, bounds: bounds, showCopyLink: showCopyLink = false }) {\n const focusState = (0, $9HnAS$macrostratmapboxreact.useFocusState)(position);\n const copyLinkIsVisible = (0, $9HnAS$macrostratmapboxreact.isCentered)(focusState) && showCopyLink;\n return $1a913554a5c0869b$var$h(\"div.position-controls\", [\n $1a913554a5c0869b$var$h((0, $9HnAS$macrostratmapboxreact.LocationFocusButton), {\n location: position,\n bounds: bounds,\n focusState: focusState\n }, []),\n $1a913554a5c0869b$var$h.if(copyLinkIsVisible && position != null)($1a913554a5c0869b$var$CopyLinkButton, {\n itemName: \"position\"\n })\n ]);\n}\nfunction $1a913554a5c0869b$var$CopyLinkButton({ itemName: itemName, children: children, onClick: onClick, ...rest }) {\n const toaster = (0, $9HnAS$macrostratuicomponents.useToaster)();\n let message = `Copied link`;\n if (itemName != null) message += ` to ${itemName}`;\n message += \"!\";\n return $1a913554a5c0869b$var$h((0, $9HnAS$blueprintjscore.Button), {\n className: \"copy-link-button\",\n rightIcon: $1a913554a5c0869b$var$h((0, $9HnAS$blueprintjscore.Icon), {\n icon: \"link\",\n size: 12\n }),\n minimal: true,\n small: true,\n onClick () {\n navigator.clipboard.writeText(window.location.href).then(()=>{\n toaster?.show({\n message: message,\n intent: \"success\",\n icon: \"clipboard\",\n timeout: 1000\n });\n onClick?.();\n }, ()=>{\n toaster?.show({\n message: \"Failed to copy link\",\n intent: \"danger\",\n icon: \"error\",\n timeout: 1000\n });\n });\n },\n ...rest\n }, children ?? \"Copy link\");\n}\nfunction $1a913554a5c0869b$export$e9ff14c4822c2e8c(props) {\n const { onClose: onClose, position: position, bounds: bounds, zoom: zoom = 7, elevation: elevation, showCopyPositionButton: showCopyPositionButton, fixedHeight: fixedHeight = false, children: children, className: className } = props;\n let leftButton = null;\n if (bounds != null || position != null) leftButton = $1a913554a5c0869b$var$h($1a913554a5c0869b$var$PositionButton, {\n position: position,\n bounds: bounds,\n showCopyLink: showCopyPositionButton\n });\n return $1a913554a5c0869b$var$h(\"header.location-panel-header\", {\n className: (0, ($parcel$interopDefault($9HnAS$classnames)))(className, {\n \"fixed-height\": fixedHeight\n })\n }, [\n leftButton,\n children,\n $1a913554a5c0869b$var$h(\"div.spacer\"),\n $1a913554a5c0869b$var$h.if(position != null)((0, $66CcX.LngLatCoords), {\n position: position,\n zoom: zoom,\n className: \"infodrawer-header-item\"\n }),\n $1a913554a5c0869b$var$h.if(elevation != null)((0, $66CcX.Elevation), {\n elevation: elevation,\n className: \"infodrawer-header-item\"\n }),\n $1a913554a5c0869b$var$h.if(onClose != null)((0, $9HnAS$blueprintjscore.Button), {\n minimal: true,\n icon: \"cross\",\n onClick: onClose\n })\n ]);\n}\n\n\n//# sourceMappingURL=map-interface.bc0fb98b.js.map\n","import { Icon, Button } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useToaster } from \"@macrostrat/ui-components\";\nimport { LngLatCoords, Elevation } from \"../location-info\";\nimport {\n LocationFocusButton,\n useFocusState,\n isCentered,\n} from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\nimport type { ReactNode } from \"react\";\nimport type { LngLatBounds, LngLatLike } from \"mapbox-gl\";\n\nconst h = hyper.styled(styles);\n\nfunction PositionButton({ position, bounds, showCopyLink = false }) {\n const focusState = useFocusState(position);\n\n const copyLinkIsVisible = isCentered(focusState) && showCopyLink;\n\n return h(\"div.position-controls\", [\n h(LocationFocusButton, { location: position, bounds, focusState }, []),\n h.if(copyLinkIsVisible && position != null)(CopyLinkButton, {\n itemName: \"position\",\n }),\n ]);\n}\n\nfunction CopyLinkButton({ itemName, children, onClick, ...rest }) {\n const toaster = useToaster();\n\n let message = `Copied link`;\n if (itemName != null) {\n message += ` to ${itemName}`;\n }\n message += \"!\";\n\n return h(\n Button,\n {\n className: \"copy-link-button\",\n rightIcon: h(Icon, { icon: \"link\", size: 12 }),\n minimal: true,\n small: true,\n onClick() {\n navigator.clipboard.writeText(window.location.href).then(\n () => {\n toaster?.show({\n message,\n intent: \"success\",\n icon: \"clipboard\",\n timeout: 1000,\n });\n onClick?.();\n },\n () => {\n toaster?.show({\n message: \"Failed to copy link\",\n intent: \"danger\",\n icon: \"error\",\n timeout: 1000,\n });\n },\n );\n },\n ...rest,\n },\n children ?? \"Copy link\",\n );\n}\n\nexport interface InfoDrawerHeaderProps {\n onClose?: () => void;\n position?: LngLatLike;\n zoom?: number;\n elevation?: number;\n showCopyPositionButton?: boolean;\n bounds?: LngLatBounds;\n fixedHeight?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport function InfoDrawerHeader(props: InfoDrawerHeaderProps) {\n const {\n onClose,\n position,\n bounds,\n zoom = 7,\n elevation,\n showCopyPositionButton,\n fixedHeight = false,\n children,\n className,\n } = props;\n\n let leftButton = null;\n if (bounds != null || position != null) {\n leftButton = h(PositionButton, {\n position,\n bounds,\n showCopyLink: showCopyPositionButton,\n });\n }\n\n return h(\n \"header.location-panel-header\",\n {\n className: classNames(className, { \"fixed-height\": fixedHeight }),\n },\n [\n leftButton,\n children,\n h(\"div.spacer\"),\n h.if(position != null)(LngLatCoords, {\n position,\n zoom,\n className: \"infodrawer-header-item\",\n }),\n h.if(elevation != null)(Elevation, {\n elevation,\n className: \"infodrawer-header-item\",\n }),\n h.if(onClose != null)(Button, {\n minimal: true,\n icon: \"cross\",\n onClick: onClose,\n }),\n ],\n );\n}\n"],"names":["require","$9HnAS$blueprintjscore","$9HnAS$macrostrathyper","$9HnAS$macrostratuicomponents","$9HnAS$macrostratmapboxreact","$9HnAS$classnames","$parcel$interopDefault","a","__esModule","default","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$2UJTP","$66CcX","$1a913554a5c0869b$var$h","styled","$1a913554a5c0869b$var$PositionButton","position","bounds","showCopyLink","focusState","useFocusState","copyLinkIsVisible","isCentered","LocationFocusButton","location","if","$1a913554a5c0869b$var$CopyLinkButton","itemName","children","onClick","rest","toaster","useToaster","message","Button","className","rightIcon","Icon","icon","size","minimal","small","navigator","clipboard","writeText","window","href","then","show","intent","timeout","$1a913554a5c0869b$export$e9ff14c4822c2e8c","props","onClose","zoom","elevation","showCopyPositionButton","fixedHeight","leftButton","LngLatCoords","Elevation"],"version":3,"file":"map-interface.bc0fb98b.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
require("./map-interface.2d12b35c.js"),require("./map-interface.b14f08e8.js"),require("./map-interface.ed6b5586.js"),require("./map-interface.eb663cae.js"),require("./map-interface.cf540298.js"),require("./map-interface.20c346ba.js"),require("./map-interface.83fa8028.js"),require("./map-interface.992dea73.js"),require("./map-interface.62b147ce.js");var $8RvAA$blueprintjscore=require("@blueprintjs/core"),$8RvAA$macrostrathyper=require("@macrostrat/hyper"),$8RvAA$macrostratuicomponents=require("@macrostrat/ui-components"),$8RvAA$mapboxgl=require("mapbox-gl"),$8RvAA$react=require("react");function $parcel$interopDefault(e){return e&&e.__esModule?e.default:e}function $parcel$export(e,r,a,t){Object.defineProperty(e,r,{get:a,set:t,enumerable:!0,configurable:!0})}var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequirea149;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var r=$parcel$inits[e];delete $parcel$inits[e];var a={id:e,exports:{}};return $parcel$modules[e]=a,r.call(a.exports,a,a.exports),a.exports}var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}).register=function(e,r){$parcel$inits[e]=r},$parcel$global.parcelRequirea149=parcelRequire);var parcelRegister=parcelRequire.register;$parcel$export(module.exports,"h",()=>$0bad82db04876d25$export$dda1d9f60106f0e9),$parcel$export(module.exports,"MapInspectorV2",()=>$0bad82db04876d25$export$eab3034e57b46e26),$parcel$export(module.exports,"DevMapPage",()=>$0bad82db04876d25$export$2391061fbdfb71ef);var $2mAQJ=parcelRequire("2mAQJ"),$lw3Ik=parcelRequire("lw3Ik"),$d7LVS=parcelRequire("d7LVS"),$7CmOU=parcelRequire("7CmOU"),$6t6Bb=parcelRequire("6t6Bb"),$3wYIs=parcelRequire("3wYIs"),$7gWgo=parcelRequire("7gWgo"),$2DICz=parcelRequire("2DICz"),$gnyJS=parcelRequire("gnyJS");let $0bad82db04876d25$export$dda1d9f60106f0e9=$parcel$interopDefault($8RvAA$macrostrathyper).styled($parcel$interopDefault($7gWgo));function $0bad82db04876d25$export$eab3034e57b46e26({title:e="Map inspector",headerElement:r=null,transformRequest:a=null,mapPosition:t=null,mapboxToken:l=null,overlayStyle:d=null,controls:o=null,children:$=null,style:n,bounds:c=null,focusedSource:p=null,focusedSourceTitle:i=null,fitViewport:u=!0,styleType:s="macrostrat"}){let f=(0,$8RvAA$macrostratuicomponents.useDarkMode)(),b=f?.isEnabled;null!=l&&($parcel$interopDefault($8RvAA$mapboxgl).accessToken=l);let m=(0,$7CmOU.useBasicMapStyle)({styleType:s});n??(n=m);let[x,R]=(0,$8RvAA$react.useState)(!1),[A,S]=(0,$8RvAA$macrostratuicomponents.useStoredState)("macrostrat:dev-map-page",{showTileExtent:!1,xRay:!1}),{showTileExtent:g,xRay:q}=A,[v,y]=(0,$8RvAA$react.useState)(null);(0,$8RvAA$react.useEffect)(()=>{(0,$2mAQJ.buildInspectorStyle)(n,d,{mapboxToken:l,inDarkMode:b,xRay:q}).then(y)},[n,q,l,b,d]);let[_,h]=(0,$8RvAA$react.useState)(null),[E,w]=(0,$8RvAA$react.useState)(null),H=(0,$8RvAA$react.useCallback)(e=>{h(e)},[]),I=null;null!=_&&(I=$0bad82db04876d25$export$dda1d9f60106f0e9($6t6Bb.LocationPanel,{onClose(){h(null)},position:_},[$0bad82db04876d25$export$dda1d9f60106f0e9($gnyJS.TileInfo,{feature:E?.[0]??null,showExtent:g,setShowExtent(){S({...A,showTileExtent:!g})}}),$0bad82db04876d25$export$dda1d9f60106f0e9($gnyJS.FeaturePanel,{features:E,focusedSource:p,focusedSourceTitle:i})]));let M=null;if(g&&E?.[0]!=null){let e=E[0];M={x:e._x,y:e._y,z:e._z}}return $0bad82db04876d25$export$dda1d9f60106f0e9($lw3Ik.MapAreaContainer,{navbar:$0bad82db04876d25$export$dda1d9f60106f0e9($d7LVS.FloatingNavbar,{rightElement:$0bad82db04876d25$export$dda1d9f60106f0e9($d7LVS.MapLoadingButton,{large:!0,active:x,onClick:()=>R(!x),style:{marginRight:"-5px"}}),headerElement:r,title:e}),contextPanel:$0bad82db04876d25$export$dda1d9f60106f0e9($lw3Ik.PanelCard,[o,$0bad82db04876d25$export$dda1d9f60106f0e9($8RvAA$blueprintjscore.Switch,{checked:q,label:"X-ray mode",onChange(){S({...A,xRay:!q})}})]),detailPanel:I,contextPanelOpen:x,fitViewport:u},$0bad82db04876d25$export$dda1d9f60106f0e9($3wYIs.MapView,{style:v,transformRequest:a,mapPosition:t,projection:{name:"globe"},mapboxToken:l,bounds:c},[$0bad82db04876d25$export$dda1d9f60106f0e9($gnyJS.FeatureSelectionHandler,{selectedLocation:_,setFeatures:w}),$0bad82db04876d25$export$dda1d9f60106f0e9($7CmOU.MapMarker,{position:_,setPosition:H}),$0bad82db04876d25$export$dda1d9f60106f0e9($2DICz.TileExtentLayer,{tile:M,color:b?"white":"black"}),$]))}function $0bad82db04876d25$var$MapInspector(e){let{children:r,controls:a,...t}=e;return console.warn("MapInspector is deprecated. Use MapInspectorV2 instead"),$0bad82db04876d25$export$dda1d9f60106f0e9($0bad82db04876d25$export$eab3034e57b46e26,{...t,controls:[r,a]})}let $0bad82db04876d25$export$2391061fbdfb71ef=$0bad82db04876d25$var$MapInspector;
|
|
2
|
-
//# sourceMappingURL=map-interface.d9814996.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,Q,gD,Q,gD,Q,gD,Q,gD,Q,gD,Q,gD,Q,gD,Q,gD,Q,gD,I,uB,Q,qB,uB,Q,qB,8B,Q,6B,gB,Q,a,a,Q,S,S,uB,C,E,O,G,E,U,C,E,O,C,C,C,S,e,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,I,e,W,gB,C,E,c,C,E,c,e,iB,A,O,gB,A,C,c,S,C,E,G,K,gB,O,e,C,E,C,O,C,G,K,c,C,I,E,a,C,E,A,Q,a,C,E,C,I,E,C,G,E,Q,C,C,E,O,e,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,a,C,E,C,C,E,e,iB,C,e,I,e,c,Q,C,e,O,O,C,I,I,2C,e,O,O,C,iB,I,2C,e,O,O,C,a,I,2C,I,O,c,S,O,c,S,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AAC,CAAK,EACnC,CACF,GACD,EACD,YAAa,EACb,iBAAkB,EAClB,YAAA,CACF,EACA,0CACE,OAAA,OAAM,CACN,CACE,MAAO,EACP,iBAAA,EACA,YAAA,EACA,WAAY,CAAE,KAAM,OAAQ,EAC5B,YAAA,EACA,OAAA,CACF,EACA,CACE,0CAAE,OAAA,uBAAsB,CAAG,CACzB,iBAAkB,EAClB,YAAa,CACf,GACA,0CAAE,OAAA,SAAQ,CAAG,CACX,SAAU,EACV,YAAa,CACf,GACA,0CAAE,OAAA,eAAc,CAAG,CAAE,KAAA,EAAM,MAAO,EAAY,QAAU,OAAQ,GAChE,EACD,EAGP,CAEA,SAAS,mCAAa,CAAK,EACzB,GAAM,CAAA,SAAE,CAAQ,CAAA,SAAE,CAAQ,CAAE,GAAG,EAAM,CAAG,EAKxC,OAFA,QAAQ,IAAI,CAAC,0DAEN,0CAAE,0CAAgB,CACvB,GAAG,CAAI,CACP,SAAU,CAAC,EAAU,EAAS,AAChC,EACF,CAGO,IAAM,0CAAa","sources":["<anon>","packages/map-interface/src/dev/map-page.ts"],"sourcesContent":["require(\"./map-interface.2d12b35c.js\");\nrequire(\"./map-interface.b14f08e8.js\");\nrequire(\"./map-interface.ed6b5586.js\");\nrequire(\"./map-interface.eb663cae.js\");\nrequire(\"./map-interface.cf540298.js\");\nrequire(\"./map-interface.20c346ba.js\");\nrequire(\"./map-interface.83fa8028.js\");\nrequire(\"./map-interface.992dea73.js\");\nrequire(\"./map-interface.62b147ce.js\");\nvar $8RvAA$blueprintjscore = require(\"@blueprintjs/core\");\nvar $8RvAA$macrostrathyper = require(\"@macrostrat/hyper\");\nvar $8RvAA$macrostratuicomponents = require(\"@macrostrat/ui-components\");\nvar $8RvAA$mapboxgl = require(\"mapbox-gl\");\nvar $8RvAA$react = require(\"react\");\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, \"h\", () => $0bad82db04876d25$export$dda1d9f60106f0e9);\n$parcel$export(module.exports, \"MapInspectorV2\", () => $0bad82db04876d25$export$eab3034e57b46e26);\n$parcel$export(module.exports, \"DevMapPage\", () => $0bad82db04876d25$export$2391061fbdfb71ef);\n// Import other components\n\n\n\n\n\n\nvar $2mAQJ = parcelRequire(\"2mAQJ\");\n\nvar $lw3Ik = parcelRequire(\"lw3Ik\");\n\nvar $d7LVS = parcelRequire(\"d7LVS\");\n\nvar $7CmOU = parcelRequire(\"7CmOU\");\n\nvar $6t6Bb = parcelRequire(\"6t6Bb\");\n\nvar $3wYIs = parcelRequire(\"3wYIs\");\n\nvar $7gWgo = parcelRequire(\"7gWgo\");\n\nvar $2DICz = parcelRequire(\"2DICz\");\n\nvar $gnyJS = parcelRequire(\"gnyJS\");\nconst $0bad82db04876d25$export$dda1d9f60106f0e9 = (0, ($parcel$interopDefault($8RvAA$macrostrathyper))).styled((0, (/*@__PURE__*/$parcel$interopDefault($7gWgo))));\nfunction $0bad82db04876d25$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\" }) {\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 */ const dark = (0, $8RvAA$macrostratuicomponents.useDarkMode)();\n const isEnabled = dark?.isEnabled;\n if (mapboxToken != null) (0, ($parcel$interopDefault($8RvAA$mapboxgl))).accessToken = mapboxToken;\n const basicStyle = (0, $7CmOU.useBasicMapStyle)({\n styleType: styleType\n });\n style ?? (style = basicStyle);\n const [isOpen, setOpen] = (0, $8RvAA$react.useState)(false);\n const [state, setState] = (0, $8RvAA$macrostratuicomponents.useStoredState)(\"macrostrat:dev-map-page\", {\n showTileExtent: false,\n xRay: false\n });\n const { showTileExtent: showTileExtent, xRay: xRay } = state;\n const [actualStyle, setActualStyle] = (0, $8RvAA$react.useState)(null);\n (0, $8RvAA$react.useEffect)(()=>{\n (0, $2mAQJ.buildInspectorStyle)(style, overlayStyle, {\n mapboxToken: mapboxToken,\n inDarkMode: isEnabled,\n xRay: xRay\n }).then(setActualStyle);\n }, [\n style,\n xRay,\n mapboxToken,\n isEnabled,\n overlayStyle\n ]);\n const [inspectPosition, setInspectPosition] = (0, $8RvAA$react.useState)(null);\n const [data, setData] = (0, $8RvAA$react.useState)(null);\n const onSelectPosition = (0, $8RvAA$react.useCallback)((position)=>{\n setInspectPosition(position);\n }, []);\n let detailElement = null;\n if (inspectPosition != null) detailElement = $0bad82db04876d25$export$dda1d9f60106f0e9((0, $6t6Bb.LocationPanel), {\n onClose () {\n setInspectPosition(null);\n },\n position: inspectPosition\n }, [\n $0bad82db04876d25$export$dda1d9f60106f0e9((0, $gnyJS.TileInfo), {\n feature: data?.[0] ?? null,\n showExtent: showTileExtent,\n setShowExtent () {\n setState({\n ...state,\n showTileExtent: !showTileExtent\n });\n }\n }),\n $0bad82db04876d25$export$dda1d9f60106f0e9((0, $gnyJS.FeaturePanel), {\n features: data,\n focusedSource: focusedSource,\n focusedSourceTitle: focusedSourceTitle\n })\n ]);\n let tile = null;\n if (showTileExtent && data?.[0] != null) {\n let f = data[0];\n tile = {\n x: f._x,\n y: f._y,\n z: f._z\n };\n }\n return $0bad82db04876d25$export$dda1d9f60106f0e9((0, $lw3Ik.MapAreaContainer), {\n navbar: $0bad82db04876d25$export$dda1d9f60106f0e9((0, $d7LVS.FloatingNavbar), {\n rightElement: $0bad82db04876d25$export$dda1d9f60106f0e9((0, $d7LVS.MapLoadingButton), {\n large: true,\n active: isOpen,\n onClick: ()=>setOpen(!isOpen),\n style: {\n marginRight: \"-5px\"\n }\n }),\n headerElement: headerElement,\n title: title\n }),\n contextPanel: $0bad82db04876d25$export$dda1d9f60106f0e9((0, $lw3Ik.PanelCard), [\n controls,\n $0bad82db04876d25$export$dda1d9f60106f0e9((0, $8RvAA$blueprintjscore.Switch), {\n checked: xRay,\n label: \"X-ray mode\",\n onChange () {\n setState({\n ...state,\n xRay: !xRay\n });\n }\n })\n ]),\n detailPanel: detailElement,\n contextPanelOpen: isOpen,\n fitViewport: fitViewport\n }, $0bad82db04876d25$export$dda1d9f60106f0e9((0, $3wYIs.MapView), {\n style: actualStyle,\n transformRequest: transformRequest,\n mapPosition: mapPosition,\n projection: {\n name: \"globe\"\n },\n mapboxToken: mapboxToken,\n bounds: bounds\n }, [\n $0bad82db04876d25$export$dda1d9f60106f0e9((0, $gnyJS.FeatureSelectionHandler), {\n selectedLocation: inspectPosition,\n setFeatures: setData\n }),\n $0bad82db04876d25$export$dda1d9f60106f0e9((0, $7CmOU.MapMarker), {\n position: inspectPosition,\n setPosition: onSelectPosition\n }),\n $0bad82db04876d25$export$dda1d9f60106f0e9((0, $2DICz.TileExtentLayer), {\n tile: tile,\n color: isEnabled ? \"white\" : \"black\"\n }),\n children\n ]));\n}\nfunction $0bad82db04876d25$var$MapInspector(props) {\n const { children: children, controls: controls, ...rest } = props;\n /** Compatibility wrapper for MapInspectorV2 */ // React warning about this legacy usage\n console.warn(\"MapInspector is deprecated. Use MapInspectorV2 instead\");\n return $0bad82db04876d25$export$dda1d9f60106f0e9($0bad82db04876d25$export$eab3034e57b46e26, {\n ...rest,\n controls: [\n children,\n controls\n ]\n });\n}\nconst $0bad82db04876d25$export$2391061fbdfb71ef = $0bad82db04876d25$var$MapInspector;\n\n\n//# sourceMappingURL=map-interface.d9814996.js.map\n","// 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, useBasicMapStyle } 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 const basicStyle = useBasicMapStyle({ styleType });\n style ??= basicStyle;\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":["require","$8RvAA$blueprintjscore","$8RvAA$macrostrathyper","$8RvAA$macrostratuicomponents","$8RvAA$mapboxgl","$8RvAA$react","$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","$0bad82db04876d25$export$dda1d9f60106f0e9","$0bad82db04876d25$export$eab3034e57b46e26","$0bad82db04876d25$export$2391061fbdfb71ef","$2mAQJ","$lw3Ik","$d7LVS","$7CmOU","$6t6Bb","$3wYIs","$7gWgo","$2DICz","$gnyJS","styled","title","headerElement","transformRequest","mapPosition","mapboxToken","overlayStyle","controls","children","style","bounds","focusedSource","focusedSourceTitle","fitViewport","styleType","dark","useDarkMode","isEnabled","accessToken","basicStyle","useBasicMapStyle","isOpen","setOpen","useState","state","setState","useStoredState","showTileExtent","xRay","actualStyle","setActualStyle","useEffect","buildInspectorStyle","inDarkMode","then","inspectPosition","setInspectPosition","data","setData","onSelectPosition","useCallback","position","detailElement","LocationPanel","onClose","TileInfo","feature","showExtent","setShowExtent","FeaturePanel","features","tile","f","x","_x","y","_y","z","_z","MapAreaContainer","navbar","FloatingNavbar","rightElement","MapLoadingButton","large","active","onClick","marginRight","contextPanel","PanelCard","Switch","checked","label","onChange","detailPanel","contextPanelOpen","MapView","projection","name","FeatureSelectionHandler","selectedLocation","setFeatures","MapMarker","setPosition","TileExtentLayer","color","$0bad82db04876d25$var$MapInspector","props","rest","console","warn"],"version":3,"file":"map-interface.d9814996.js.map","sourceRoot":"../../../../"}
|