@macrostrat/map-interface 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -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.17e81e8a.js → map-interface.28d1a6b7.js} +10 -8
- package/dist/cjs/map-interface.28d1a6b7.js.map +1 -0
- package/dist/cjs/{map-interface.5cea0ff4.js → map-interface.3bc4f731.js} +3 -3
- package/dist/cjs/{map-interface.5cea0ff4.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/cjs/{map-interface.175c4635.js → map-interface.f8826069.js} +12 -17
- package/dist/cjs/map-interface.f8826069.js.map +1 -0
- package/dist/esm/index.d.ts +18 -29
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/map-interface.22ea3934.js +41 -0
- package/dist/esm/map-interface.22ea3934.js.map +1 -0
- 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.3248abc7.js → map-interface.90d9023c.js} +3 -3
- package/dist/esm/{map-interface.3248abc7.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.00058d23.js → map-interface.ec2278ab.js} +10 -8
- 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.0dc4417b.js +2 -0
- package/dist/node/map-interface.0dc4417b.js.map +1 -0
- 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.7295b0a2.js +2 -0
- package/dist/node/map-interface.7295b0a2.js.map +1 -0
- package/dist/node/map-interface.992dea73.js +2 -0
- package/dist/node/map-interface.992dea73.js.map +1 -0
- package/dist/node/{map-interface.d16a06b1.js → map-interface.f3e12e03.js} +2 -2
- package/dist/node/{map-interface.d16a06b1.js.map → map-interface.f3e12e03.js.map} +1 -1
- package/package.json +3 -3
- package/src/dev/map-page.ts +27 -20
- package/src/dev/tile-extent.ts +17 -18
- package/src/helpers.ts +4 -4
- package/src/location-panel/header.ts +2 -5
- package/src/map-view.ts +77 -52
- package/dist/cjs/map-interface.175c4635.js.map +0 -1
- package/dist/cjs/map-interface.17e81e8a.js.map +0 -1
- package/dist/cjs/map-interface.1d19056e.js.map +0 -1
- package/dist/cjs/map-interface.e7194f92.js.map +0 -1
- package/dist/esm/map-interface.00058d23.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.f107347b.js +0 -46
- package/dist/esm/map-interface.f107347b.js.map +0 -1
- package/dist/node/map-interface.02dd6884.js +0 -2
- package/dist/node/map-interface.02dd6884.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.44d3f3bf.js +0 -2
- package/dist/node/map-interface.44d3f3bf.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.eb663cae.js.map +0 -1
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {useMapRef as $edFMK$useMapRef, useMapConditionalStyle as $edFMK$useMapConditionalStyle} from "@macrostrat/mapbox-react";
|
|
2
|
-
import {tileToGeoJSON as $edFMK$tileToGeoJSON} from "@mapbox/tilebelt";
|
|
3
|
-
import {useCallback as $edFMK$useCallback} from "react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function $1d4d29ef2725aa16$export$86c09739b12f23cd({ tile: tile, color: color = "red" }) {
|
|
9
|
-
const styleCallback = (0, $edFMK$useCallback)((map, val)=>{
|
|
10
|
-
const style = map.getStyle();
|
|
11
|
-
if (style.layers == null) return;
|
|
12
|
-
style.layers = style.layers.filter((l)=>l.id != "tile-extent");
|
|
13
|
-
if (val == null) return map.setStyle(style);
|
|
14
|
-
const { x: x, y: y, z: z } = val;
|
|
15
|
-
const extent = (0, $edFMK$tileToGeoJSON)([
|
|
16
|
-
x,
|
|
17
|
-
y,
|
|
18
|
-
z
|
|
19
|
-
]);
|
|
20
|
-
const source = {
|
|
21
|
-
type: "geojson",
|
|
22
|
-
data: extent
|
|
23
|
-
};
|
|
24
|
-
const layer = {
|
|
25
|
-
id: "tile-extent",
|
|
26
|
-
type: "line",
|
|
27
|
-
source: "tile-extent",
|
|
28
|
-
paint: {
|
|
29
|
-
"line-color": color,
|
|
30
|
-
"line-width": 2
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
style.sources["tile-extent"] = source;
|
|
34
|
-
style.layers.push(layer);
|
|
35
|
-
map.setStyle(style);
|
|
36
|
-
}, [
|
|
37
|
-
color
|
|
38
|
-
]);
|
|
39
|
-
const map = (0, $edFMK$useMapRef)();
|
|
40
|
-
(0, $edFMK$useMapConditionalStyle)(map, tile, styleCallback);
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export {$1d4d29ef2725aa16$export$86c09739b12f23cd as TileExtentLayer};
|
|
46
|
-
//# sourceMappingURL=map-interface.f107347b.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAMO,SAAS,0CAAgB,QAC9B,IAAI,SACJ,QAAQ,OAIT;IACC,MAAM,gBAAgB,CAAA,GAAA,kBAAU,EAC9B,CAAC,KAAK;QACJ,MAAM,QAAQ,IAAI,QAAQ;QAC1B,IAAI,MAAM,MAAM,IAAI,MAAM;QAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAM,EAAE,EAAE,IAAI;QAClD,IAAI,OAAO,MACT,OAAO,IAAI,QAAQ,CAAC;QAEtB,MAAM,KAAE,CAAC,KAAE,CAAC,KAAE,CAAC,EAAE,GAAG;QACpB,MAAM,SAAS,CAAA,GAAA,oBAAY,EAAE;YAAC;YAAG;YAAG;SAAE;QACtC,MAAM,SAAS;YACb,MAAM;YACN,MAAM;QACR;QACA,MAAM,QAAQ;YACZ,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,OAAO;gBACL,cAAc;gBACd,cAAc;YAChB;QACF;QACA,MAAM,OAAO,CAAC,cAAc,GAAG;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC;QAClB,IAAI,QAAQ,CAAC;IACf,GACA;QAAC;KAAM;IAET,MAAM,MAAM,CAAA,GAAA,gBAAQ;IACpB,CAAA,GAAA,6BAAqB,EAAE,KAAK,MAAM;IAClC,OAAO;AACT","sources":["packages/map-interface/src/dev/tile-extent.ts"],"sourcesContent":["import { useMapConditionalStyle, useMapRef } from \"@macrostrat/mapbox-react\";\nimport { tileToGeoJSON } from \"@mapbox/tilebelt\";\nimport { useCallback } from \"react\";\n\ntype TileIndex = { x: number; y: number; z: number };\n\nexport function TileExtentLayer({\n tile,\n color = \"red\",\n}: {\n tile: TileIndex | null;\n color?: string;\n}) {\n const styleCallback = useCallback(\n (map, val: TileIndex) => {\n const style = map.getStyle();\n if (style.layers == null) return;\n style.layers = style.layers.filter((l) => l.id != \"tile-extent\");\n if (val == null) {\n return map.setStyle(style);\n }\n const { x, y, z } = val;\n const extent = tileToGeoJSON([x, y, z]);\n const source = {\n type: \"geojson\",\n data: extent,\n };\n const layer = {\n id: \"tile-extent\",\n type: \"line\",\n source: \"tile-extent\",\n paint: {\n \"line-color\": color,\n \"line-width\": 2,\n },\n };\n style.sources[\"tile-extent\"] = source;\n style.layers.push(layer);\n map.setStyle(style);\n },\n [color],\n );\n const map = useMapRef();\n useMapConditionalStyle(map, tile, styleCallback);\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.f107347b.js.map"}
|
|
@@ -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.44d3f3bf.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),n??(n=(0,$7CmOU.useBasicMapStyle)({styleType:s}));let[m,x]=(0,$8RvAA$react.useState)(!1),[R,A]=(0,$8RvAA$macrostratuicomponents.useStoredState)("macrostrat:dev-map-page",{showTileExtent:!1,xRay:!1}),{showTileExtent:S,xRay:g}=R,[q,v]=(0,$8RvAA$react.useState)(null);(0,$8RvAA$react.useEffect)(()=>{(0,$2mAQJ.buildInspectorStyle)(n,d,{mapboxToken:l,inDarkMode:b,xRay:g}).then(v)},[n,g,l,b,d]);let[y,_]=(0,$8RvAA$react.useState)(null),[h,E]=(0,$8RvAA$react.useState)(null),w=(0,$8RvAA$react.useCallback)(e=>{_(e)},[]),H=null;null!=y&&(H=$0bad82db04876d25$export$dda1d9f60106f0e9($6t6Bb.LocationPanel,{onClose(){_(null)},position:y},[$0bad82db04876d25$export$dda1d9f60106f0e9($gnyJS.TileInfo,{feature:h?.[0]??null,showExtent:S,setShowExtent(){A({...R,showTileExtent:!S})}}),$0bad82db04876d25$export$dda1d9f60106f0e9($gnyJS.FeaturePanel,{features:h,focusedSource:p,focusedSourceTitle:i})]));let I=null;if(S&&h?.[0]!=null){let e=h[0];I={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:m,onClick:()=>x(!m),style:{marginRight:"-5px"}}),headerElement:r,title:e}),contextPanel:$0bad82db04876d25$export$dda1d9f60106f0e9($lw3Ik.PanelCard,[o,$0bad82db04876d25$export$dda1d9f60106f0e9($8RvAA$blueprintjscore.Switch,{checked:g,label:"X-ray mode",onChange(){A({...R,xRay:!g})}})]),detailPanel:H,contextPanelOpen:m,fitViewport:u},$0bad82db04876d25$export$dda1d9f60106f0e9($3wYIs.MapView,{style:q,transformRequest:a,mapPosition:t,projection:{name:"globe"},mapboxToken:l,bounds:c},[$0bad82db04876d25$export$dda1d9f60106f0e9($gnyJS.FeatureSelectionHandler,{selectedLocation:y,setFeatures:E}),$0bad82db04876d25$export$dda1d9f60106f0e9($7CmOU.MapMarker,{position:y,setPosition:w}),$0bad82db04876d25$export$dda1d9f60106f0e9($2DICz.TileExtentLayer,{tile:I,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.02dd6884.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,O,c,S,O,c,S,O,c,S,O,c,S,O,c,S,O,c,S,O,c,SCqBO,IAAM,0CAAI,AAAA,uBAAA,wBAAM,MAAM,CAAC,uBAAA,SAEvB,SAAS,0CAAe,CAAA,MAC7B,E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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.44d3f3bf.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 style ?? (style = (0, $7CmOU.useBasicMapStyle)({\n styleType: styleType\n }));\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.02dd6884.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 style ??= useBasicMapStyle({ styleType });\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","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.02dd6884.js.map","sourceRoot":"../../../../"}
|
|
@@ -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$c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esContent":["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
|
-
var $8kl9w$macrostratmapboxreact=require("@macrostrat/mapbox-react"),$8kl9w$mapboxtilebelt=require("@mapbox/tilebelt"),$8kl9w$react=require("react");function $parcel$export(e,t,l,r){Object.defineProperty(e,t,{get:l,set:r,enumerable:!0,configurable:!0})}function $d89f06dba650370d$export$86c09739b12f23cd({tile:e,color:t="red"}){let l=(0,$8kl9w$react.useCallback)((e,l)=>{let r=e.getStyle();if(null==r.layers)return;if(r.layers=r.layers.filter(e=>"tile-extent"!=e.id),null==l)return e.setStyle(r);let{x:a,y:o,z:i}=l,c=(0,$8kl9w$mapboxtilebelt.tileToGeoJSON)([a,o,i]);r.sources["tile-extent"]={type:"geojson",data:c},r.layers.push({id:"tile-extent",type:"line",source:"tile-extent",paint:{"line-color":t,"line-width":2}}),e.setStyle(r)},[t]),r=(0,$8kl9w$macrostratmapboxreact.useMapRef)();return(0,$8kl9w$macrostratmapboxreact.useMapConditionalStyle)(r,e,l),null}$parcel$export(module.exports,"TileExtentLayer",()=>$d89f06dba650370d$export$86c09739b12f23cd);
|
|
2
|
-
//# sourceMappingURL=map-interface.44d3f3bf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,I,6B,Q,4B,sB,Q,oB,a,Q,S,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,CCMO,SAAS,0CAAgB,CAAA,KAC9B,CAAI,CAAA,MACJ,EAAQ,KAAA,CAIT,EACC,IAAM,EAAgB,AAAA,CAAA,EAAA,aAAA,WAAU,AAAV,EACpB,CAAC,EAAK,KACJ,IAAM,EAAQ,EAAI,QAAQ,GAC1B,GAAI,AAAgB,MAAhB,EAAM,MAAM,CAAU,OAE1B,GADA,EAAM,MAAM,CAAG,EAAM,MAAM,CAAC,MAAM,CAAC,AAAC,GAAM,AAAQ,eAAR,EAAE,EAAE,EAC1C,AAAO,MAAP,EACF,OAAO,EAAI,QAAQ,CAAC,GAEtB,GAAM,CAAA,EAAE,CAAC,CAAA,EAAE,CAAC,CAAA,EAAE,CAAC,CAAE,CAAG,EACd,EAAS,AAAA,CAAA,EAAA,sBAAA,aAAY,AAAZ,EAAc,CAAC,EAAG,EAAG,EAAE,CActC,CAAA,EAAM,OAAO,CAAC,cAAc,CAbb,CACb,KAAM,UACN,KAAM,CACR,EAWA,EAAM,MAAM,CAAC,IAAI,CAVH,CACZ,GAAI,cACJ,KAAM,OACN,OAAQ,cACR,MAAO,CACL,aAAc,EACd,aAAc,CAChB,CACF,GAGA,EAAI,QAAQ,CAAC,EACf,EACA,CAAC,EAAM,EAEH,EAAM,AAAA,CAAA,EAAA,6BAAA,SAAQ,AAAR,IAEZ,MADA,AAAA,CAAA,EAAA,6BAAA,sBAAqB,AAArB,EAAuB,EAAK,EAAM,GAC3B,IACT,C,e,O,O,C,kB,I","sources":["<anon>","packages/map-interface/src/dev/tile-extent.ts"],"sourcesContent":["var $8kl9w$macrostratmapboxreact = require(\"@macrostrat/mapbox-react\");\nvar $8kl9w$mapboxtilebelt = require(\"@mapbox/tilebelt\");\nvar $8kl9w$react = require(\"react\");\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$parcel$export(module.exports, \"TileExtentLayer\", () => $d89f06dba650370d$export$86c09739b12f23cd);\n\n\n\nfunction $d89f06dba650370d$export$86c09739b12f23cd({ tile: tile, color: color = \"red\" }) {\n const styleCallback = (0, $8kl9w$react.useCallback)((map, val)=>{\n const style = map.getStyle();\n if (style.layers == null) return;\n style.layers = style.layers.filter((l)=>l.id != \"tile-extent\");\n if (val == null) return map.setStyle(style);\n const { x: x, y: y, z: z } = val;\n const extent = (0, $8kl9w$mapboxtilebelt.tileToGeoJSON)([\n x,\n y,\n z\n ]);\n const source = {\n type: \"geojson\",\n data: extent\n };\n const layer = {\n id: \"tile-extent\",\n type: \"line\",\n source: \"tile-extent\",\n paint: {\n \"line-color\": color,\n \"line-width\": 2\n }\n };\n style.sources[\"tile-extent\"] = source;\n style.layers.push(layer);\n map.setStyle(style);\n }, [\n color\n ]);\n const map = (0, $8kl9w$macrostratmapboxreact.useMapRef)();\n (0, $8kl9w$macrostratmapboxreact.useMapConditionalStyle)(map, tile, styleCallback);\n return null;\n}\n\n\n//# sourceMappingURL=map-interface.44d3f3bf.js.map\n","import { useMapConditionalStyle, useMapRef } from \"@macrostrat/mapbox-react\";\nimport { tileToGeoJSON } from \"@mapbox/tilebelt\";\nimport { useCallback } from \"react\";\n\ntype TileIndex = { x: number; y: number; z: number };\n\nexport function TileExtentLayer({\n tile,\n color = \"red\",\n}: {\n tile: TileIndex | null;\n color?: string;\n}) {\n const styleCallback = useCallback(\n (map, val: TileIndex) => {\n const style = map.getStyle();\n if (style.layers == null) return;\n style.layers = style.layers.filter((l) => l.id != \"tile-extent\");\n if (val == null) {\n return map.setStyle(style);\n }\n const { x, y, z } = val;\n const extent = tileToGeoJSON([x, y, z]);\n const source = {\n type: \"geojson\",\n data: extent,\n };\n const layer = {\n id: \"tile-extent\",\n type: \"line\",\n source: \"tile-extent\",\n paint: {\n \"line-color\": color,\n \"line-width\": 2,\n },\n };\n style.sources[\"tile-extent\"] = source;\n style.layers.push(layer);\n map.setStyle(style);\n },\n [color],\n );\n const map = useMapRef();\n useMapConditionalStyle(map, tile, styleCallback);\n return null;\n}\n"],"names":["$8kl9w$macrostratmapboxreact","require","$8kl9w$mapboxtilebelt","$8kl9w$react","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$d89f06dba650370d$export$86c09739b12f23cd","tile","color","styleCallback","useCallback","map","val","style","getStyle","layers","filter","l","id","setStyle","x","y","z","extent","tileToGeoJSON","sources","type","data","push","source","paint","useMapRef","useMapConditionalStyle","module","exports"],"version":3,"file":"map-interface.44d3f3bf.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,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,O,c,S,O,c,SCcA,IAAM,wBAAI,AAAA,uBAAA,wBAAM,MAAM,CAAC,uBAAA,SAEvB,SAAS,qCAAe,CAAA,SAAE,CAAQ,CAAA,OAAE,CAAM,CAAA,aAAE,EAAe,CAAA,CAAA,CAAO,EAChE,IAAM,EAAa,AAAA,CAAA,EAAA,6BAAA,aAAY,AAAZ,EAAc,GAE3B,EAAoB,AAAA,CAAA,EAAA,6BAAA,UAAS,AAAT,EAAW,IAAe,EAEpD,OAAO,wBAAE,wBAAyB,CAChC,wBAAE,6BAAA,mBAAkB,CAAG,CAAE,SAAU,EAAU,OAAA,EAAQ,WAAA,CAAW,EAAG,EAAE,EACrE,wBAAE,EAAE,CAAC,GAAqB,AAAY,MA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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 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,Q,gD,I,6B,Q,4B,a,Q,S,kB,Q,c,yB,Q,uB,6B,Q,4B,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,iB,C,e,I,e,c,Q,C,e,O,O,C,mB,I,2C,e,O,O,C,oB,I,2C,e,O,O,C,mB,I,2C,e,O,O,C,qB,I,2C,e,O,O,C,Y,I,2C,e,O,O,C,mB,I,2C,e,O,O,C,mB,I,2C,e,O,O,C,oB,I,2C,I,O,c,SCiBO,SAAS,0CAAiB,CAAA,aAAE,CAAY,CAAE,EAC/C,IAAM,EAAS,AAAA,CAAA,EAAA,6BAAA,SAAQ,AAAR,IAET,EAAkB,AAAA,CAAA,EAAA,aAAA,MAAK,AAAL,EACtB,AAAA,CAAA,EAAA,kBAAA,QAAO,AAAP,EAAS,KACP,EAAO,OAAO,EAAE,QAClB,EAA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A,CAAE,UAAA,EAAW,WAAA,CAAW,CAAA,EAC9B,CAAC,EAAW,EAAW,EAG5B,CAEO,SAAS,0CAAiB,CAGhC,EACC,GAAM,CAAA,UAAE,EAAY,YAAA,CAAA,WAAc,EAAa,CAAA,CAAA,CAAO,CAAG,GAAQ,CAAC,QAElE,AAAI,AAAa,cAAb,EACK,EACH,sEACA,sEAEG,EACH,kCACA,kCAER,CAEO,IAAM,0CAAoB","sources":["<anon>","packages/map-interface/src/helpers.ts"],"sourcesContent":["require(\"./map-interface.713361a4.js\");\nvar $2crMj$macrostratmapboxreact = require(\"@macrostrat/mapbox-react\");\nvar $2crMj$react = require(\"react\");\nvar $2crMj$underscore = require(\"underscore\");\nvar $2crMj$useresizeobserver = require(\"use-resize-observer\");\nvar $2crMj$macrostratmapboxutils = require(\"@macrostrat/mapbox-utils\");\nvar $2crMj$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, \"MapResizeManager\", () => $f6c715b8ad8cb91a$export$31b2e088aff2dc5d);\n$parcel$export(module.exports, \"MapPaddingManager\", () => $f6c715b8ad8cb91a$export$2ab96428dea558d6);\n$parcel$export(module.exports, \"MapMovedReporter\", () => $f6c715b8ad8cb91a$export$f6eeee399afc4e9a);\n$parcel$export(module.exports, \"MapLoadingReporter\", () => $f6c715b8ad8cb91a$export$e57f9eaa51773f82);\n$parcel$export(module.exports, \"MapMarker\", () => $f6c715b8ad8cb91a$export$5c90a91c7455938c);\n$parcel$export(module.exports, \"useBasicMapStyle\", () => $f6c715b8ad8cb91a$export$6daf1520df36ae21);\n$parcel$export(module.exports, \"getBasicMapStyle\", () => $f6c715b8ad8cb91a$export$3503bf0b3851527b);\n$parcel$export(module.exports, \"useBasicStylePair\", () => $f6c715b8ad8cb91a$export$566518253d2584f8);\n\n\n\n\n\n\nvar $R3my3 = parcelRequire(\"R3my3\");\n\nfunction $f6c715b8ad8cb91a$export$31b2e088aff2dc5d({ containerRef: containerRef }) {\n const mapRef = (0, $2crMj$macrostratmapboxreact.useMapRef)();\n const debouncedResize = (0, $2crMj$react.useRef)((0, $2crMj$underscore.debounce)(()=>{\n mapRef.current?.resize();\n }, 100));\n (0, ($parcel$interopDefault($2crMj$useresizeobserver)))({\n ref: containerRef,\n onResize: debouncedResize.current\n });\n return null;\n}\nfunction $f6c715b8ad8cb91a$export$2ab96428dea558d6({ containerRef: containerRef, parentRef: parentRef, infoMarkerPosition: infoMarkerPosition, debounceTime: debounceTime = 200 }) {\n const mapRef = (0, $2crMj$macrostratmapboxreact.useMapRef)();\n const [padding, setPadding] = (0, $2crMj$react.useState)((0, $R3my3.getMapPadding)(containerRef, parentRef));\n const _updateMapPadding = (0, $2crMj$react.useCallback)(()=>{\n const newPadding = (0, $R3my3.getMapPadding)(containerRef, parentRef);\n setPadding(newPadding);\n }, [\n containerRef.current,\n parentRef.current\n ]);\n const updateMapPadding = (0, $2crMj$react.useMemo)(()=>(0, $2crMj$underscore.debounce)(_updateMapPadding, debounceTime), [\n _updateMapPadding,\n debounceTime\n ]);\n (0, $2crMj$react.useEffect)(()=>{\n const map = mapRef.current;\n if (map == null) return;\n // Update map padding on load\n updateMapPadding();\n }, [\n mapRef.current\n ]);\n (0, ($parcel$interopDefault($2crMj$useresizeobserver)))({\n ref: parentRef,\n onResize (sz) {\n updateMapPadding();\n },\n round (n) {\n return Math.round(n);\n }\n });\n // Ideally, we would not have to do this when we know the infobox is loaded\n (0, $2crMj$macrostratmapboxreact.useMapEaseTo)({\n center: infoMarkerPosition,\n padding: padding\n });\n return null;\n}\nfunction $f6c715b8ad8cb91a$export$f6eeee399afc4e9a({ onMapMoved: onMapMoved = null }) {\n const mapRef = (0, $2crMj$macrostratmapboxreact.useMapRef)();\n const dispatch = (0, $2crMj$macrostratmapboxreact.useMapDispatch)();\n const isInitialized = (0, $2crMj$macrostratmapboxreact.useMapInitialized)();\n const mapMovedCallback = (0, $2crMj$react.useCallback)(()=>{\n const map = mapRef.current;\n if (map == null) return;\n const mapPosition = (0, $2crMj$macrostratmapboxutils.getMapPosition)(map);\n dispatch({\n type: \"map-moved\",\n payload: mapPosition\n });\n onMapMoved?.(mapPosition, map);\n }, [\n onMapMoved,\n dispatch,\n isInitialized\n ]);\n (0, $2crMj$react.useEffect)(()=>{\n // Get the current value of the map. Useful for gradually moving away\n // from class component\n const map = mapRef.current;\n if (map == null) return;\n // Update the URI when the map moves\n mapMovedCallback();\n const cb = (0, $2crMj$underscore.debounce)(mapMovedCallback, 100);\n map.on(\"moveend\", cb);\n return ()=>{\n map?.off(\"moveend\", cb);\n };\n }, [\n mapMovedCallback\n ]);\n return null;\n}\nfunction $f6c715b8ad8cb91a$export$e57f9eaa51773f82({ ignoredSources: ignoredSources, onMapLoading: onMapLoading = null, onMapIdle: onMapIdle = null, mapIsLoading: mapIsLoading }) {\n const mapRef = (0, $2crMj$macrostratmapboxreact.useMapRef)();\n const loadingRef = (0, $2crMj$react.useRef)(false);\n const dispatch = (0, $2crMj$macrostratmapboxreact.useMapDispatch)();\n const isInitialized = (0, $2crMj$macrostratmapboxreact.useMapInitialized)();\n (0, $2crMj$react.useEffect)(()=>{\n const map = mapRef.current;\n const mapIsLoading = loadingRef.current;\n if (map == null) return;\n let didSendLoading = false;\n const loadingCallback = (evt)=>{\n if (ignoredSources.includes(evt.sourceId) || mapIsLoading) return;\n if (didSendLoading) return;\n onMapLoading?.(evt);\n dispatch({\n type: \"set-loading\",\n payload: true\n });\n loadingRef.current = true;\n didSendLoading = true;\n };\n const idleCallback = (evt)=>{\n if (!mapIsLoading) return;\n dispatch({\n type: \"set-loading\",\n payload: false\n });\n loadingRef.current = false;\n onMapIdle?.(evt);\n };\n map.on(\"sourcedataloading\", loadingCallback);\n map.on(\"idle\", idleCallback);\n return ()=>{\n map?.off(\"sourcedataloading\", loadingCallback);\n map?.off(\"idle\", idleCallback);\n };\n }, [\n ignoredSources,\n mapIsLoading,\n isInitialized\n ]);\n return null;\n}\nfunction $f6c715b8ad8cb91a$export$5c90a91c7455938c({ position: position, setPosition: setPosition, centerMarker: centerMarker = true }) {\n const mapRef = (0, $2crMj$macrostratmapboxreact.useMapRef)();\n const markerRef = (0, $2crMj$react.useRef)(null);\n const isInitialized = (0, $2crMj$macrostratmapboxreact.useMapInitialized)();\n (0, $R3my3.useMapMarker)(mapRef, markerRef, position);\n (0, $2crMj$react.useEffect)(()=>{\n const map = mapRef.current;\n if (map == null || setPosition == null) return;\n const handleMapClick = (event)=>{\n setPosition(event.lngLat, event, mapRef.current);\n // We should integrate this with the \"easeToCenter\" hook\n if (centerMarker) mapRef.current?.flyTo({\n center: event.lngLat,\n duration: 800\n });\n };\n map.on(\"click\", handleMapClick);\n return ()=>{\n map?.off(\"click\", handleMapClick);\n };\n }, [\n setPosition,\n isInitialized\n ]);\n return null;\n}\nfunction $f6c715b8ad8cb91a$export$6daf1520df36ae21(opts = {}) {\n const { styleType: styleType } = opts;\n const inDarkMode = (0, $2crMj$macrostratuicomponents.useInDarkMode)();\n const props = (0, $2crMj$react.useMemo)(()=>{\n return {\n styleType: styleType,\n inDarkMode: inDarkMode\n };\n }, [\n styleType,\n inDarkMode\n ]);\n return $f6c715b8ad8cb91a$export$3503bf0b3851527b(props);\n}\nfunction $f6c715b8ad8cb91a$export$3503bf0b3851527b(opts) {\n const { styleType: styleType = \"macrostrat\", inDarkMode: inDarkMode = false } = opts ?? {};\n if (styleType == \"macrostrat\") return inDarkMode ? \"mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true\" : \"mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true\";\n else return inDarkMode ? \"mapbox://styles/mapbox/dark-v10\" : \"mapbox://styles/mapbox/light-v10\";\n}\nconst $f6c715b8ad8cb91a$export$566518253d2584f8 = $f6c715b8ad8cb91a$export$6daf1520df36ae21;\n\n\n//# sourceMappingURL=map-interface.eb663cae.js.map\n","import {\n useMapRef,\n useMapEaseTo,\n useMapDispatch,\n useMapStatus,\n useMapInitialized,\n} from \"@macrostrat/mapbox-react\";\nimport { useMemo, useRef } from \"react\";\nimport { debounce } from \"underscore\";\nimport useResizeObserver from \"use-resize-observer\";\n\nimport { getMapPosition } from \"@macrostrat/mapbox-utils\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { getMapPadding, useMapMarker } from \"./utils\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\n\nexport function MapResizeManager({ containerRef }) {\n const mapRef = useMapRef();\n\n const debouncedResize = useRef(\n debounce(() => {\n mapRef.current?.resize();\n }, 100),\n );\n\n useResizeObserver({\n ref: containerRef,\n onResize: debouncedResize.current,\n });\n\n return null;\n}\n\ninterface MapPaddingManagerProps {\n containerRef: React.RefObject<HTMLDivElement>;\n parentRef: React.RefObject<HTMLDivElement>;\n infoMarkerPosition: mapboxgl.LngLatLike;\n debounceTime?: number;\n}\n\nexport function MapPaddingManager({\n containerRef,\n parentRef,\n infoMarkerPosition,\n debounceTime = 200,\n}: MapPaddingManagerProps) {\n const mapRef = useMapRef();\n\n const [padding, setPadding] = useState(\n getMapPadding(containerRef, parentRef),\n );\n\n const _updateMapPadding = useCallback(() => {\n const newPadding = getMapPadding(containerRef, parentRef);\n setPadding(newPadding);\n }, [containerRef.current, parentRef.current]);\n\n const updateMapPadding = useMemo(\n () => debounce(_updateMapPadding, debounceTime),\n [_updateMapPadding, debounceTime],\n );\n\n useEffect(() => {\n const map = mapRef.current;\n if (map == null) return;\n // Update map padding on load\n updateMapPadding();\n }, [mapRef.current]);\n\n useResizeObserver({\n ref: parentRef,\n onResize(sz) {\n updateMapPadding();\n },\n round(n) {\n return Math.round(n);\n },\n });\n\n // Ideally, we would not have to do this when we know the infobox is loaded\n useMapEaseTo({ center: infoMarkerPosition, padding });\n\n return null;\n}\n\nexport function MapMovedReporter({ onMapMoved = null }) {\n const mapRef = useMapRef();\n const dispatch = useMapDispatch();\n const isInitialized = useMapInitialized();\n\n const mapMovedCallback = useCallback(() => {\n const map = mapRef.current;\n if (map == null) return;\n const mapPosition = getMapPosition(map);\n dispatch({ type: \"map-moved\", payload: mapPosition });\n onMapMoved?.(mapPosition, map);\n }, [onMapMoved, dispatch, isInitialized]);\n\n useEffect(() => {\n // Get the current value of the map. Useful for gradually moving away\n // from class component\n const map = mapRef.current;\n if (map == null) return;\n // Update the URI when the map moves\n mapMovedCallback();\n const cb = debounce(mapMovedCallback, 100);\n map.on(\"moveend\", cb);\n return () => {\n map?.off(\"moveend\", cb);\n };\n }, [mapMovedCallback]);\n return null;\n}\n\ninterface MapLoadingReporterProps {\n ignoredSources?: string[];\n onMapLoading?: (evt: mapboxgl.MapEvent) => void;\n onMapIdle?: (evt: mapboxgl.MapEvent) => void;\n mapIsLoading?: boolean;\n}\n\nexport function MapLoadingReporter({\n ignoredSources,\n onMapLoading = null,\n onMapIdle = null,\n mapIsLoading,\n}: MapLoadingReporterProps) {\n const mapRef = useMapRef();\n const loadingRef = useRef(false);\n const dispatch = useMapDispatch();\n const isInitialized = useMapInitialized();\n\n useEffect(() => {\n const map = mapRef.current;\n const mapIsLoading = loadingRef.current;\n if (map == null) return;\n\n let didSendLoading = false;\n\n const loadingCallback = (evt) => {\n if (ignoredSources.includes(evt.sourceId) || mapIsLoading) return;\n if (didSendLoading) return;\n onMapLoading?.(evt);\n dispatch({ type: \"set-loading\", payload: true });\n loadingRef.current = true;\n didSendLoading = true;\n };\n const idleCallback = (evt) => {\n if (!mapIsLoading) return;\n dispatch({ type: \"set-loading\", payload: false });\n loadingRef.current = false;\n onMapIdle?.(evt);\n };\n map.on(\"sourcedataloading\", loadingCallback);\n map.on(\"idle\", idleCallback);\n return () => {\n map?.off(\"sourcedataloading\", loadingCallback);\n map?.off(\"idle\", idleCallback);\n };\n }, [ignoredSources, mapIsLoading, isInitialized]);\n return null;\n}\n\nexport function MapMarker({ position, setPosition, centerMarker = true }) {\n const mapRef = useMapRef();\n const markerRef = useRef(null);\n const isInitialized = useMapInitialized();\n\n useMapMarker(mapRef, markerRef, position);\n\n useEffect(() => {\n const map = mapRef.current;\n if (map == null || setPosition == null) return;\n\n const handleMapClick = (event: mapboxgl.MapMouseEvent) => {\n setPosition(event.lngLat, event, mapRef.current);\n // We should integrate this with the \"easeToCenter\" hook\n if (centerMarker) {\n mapRef.current?.flyTo({ center: event.lngLat, duration: 800 });\n }\n };\n\n map.on(\"click\", handleMapClick);\n\n return () => {\n map?.off(\"click\", handleMapClick);\n };\n }, [setPosition, isInitialized]);\n\n return null;\n}\n\nexport function useBasicMapStyle(\n opts: {\n styleType?: \"macrostrat\" | \"standard\";\n } = {},\n) {\n const { styleType } = opts;\n const inDarkMode = useInDarkMode();\n\n const props = useMemo(() => {\n return { styleType, inDarkMode };\n }, [styleType, inDarkMode]);\n\n return getBasicMapStyle(props);\n}\n\nexport function getBasicMapStyle(opts: {\n styleType?: \"macrostrat\" | \"standard\";\n inDarkMode?: boolean;\n}) {\n const { styleType = \"macrostrat\", inDarkMode = false } = opts ?? {};\n\n if (styleType == \"macrostrat\") {\n return inDarkMode\n ? \"mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true\"\n : \"mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true\";\n } else {\n return inDarkMode\n ? \"mapbox://styles/mapbox/dark-v10\"\n : \"mapbox://styles/mapbox/light-v10\";\n }\n}\n\nexport const useBasicStylePair = useBasicMapStyle;\n"],"names":["require","$2crMj$macrostratmapboxreact","$2crMj$react","$2crMj$underscore","$2crMj$useresizeobserver","$2crMj$macrostratmapboxutils","$2crMj$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","$f6c715b8ad8cb91a$export$31b2e088aff2dc5d","$f6c715b8ad8cb91a$export$2ab96428dea558d6","$f6c715b8ad8cb91a$export$f6eeee399afc4e9a","$f6c715b8ad8cb91a$export$e57f9eaa51773f82","$f6c715b8ad8cb91a$export$5c90a91c7455938c","$f6c715b8ad8cb91a$export$6daf1520df36ae21","$f6c715b8ad8cb91a$export$3503bf0b3851527b","$f6c715b8ad8cb91a$export$566518253d2584f8","$R3my3","containerRef","mapRef","useMapRef","debouncedResize","useRef","debounce","current","resize","ref","onResize","parentRef","infoMarkerPosition","debounceTime","padding","setPadding","useState","getMapPadding","_updateMapPadding","useCallback","updateMapPadding","useMemo","useEffect","sz","round","Math","useMapEaseTo","center","onMapMoved","dispatch","useMapDispatch","isInitialized","useMapInitialized","mapMovedCallback","map","mapPosition","getMapPosition","type","payload","cb","on","off","ignoredSources","onMapLoading","onMapIdle","mapIsLoading","loadingRef","didSendLoading","loadingCallback","evt","includes","sourceId","idleCallback","position","setPosition","centerMarker","markerRef","useMapMarker","handleMapClick","event","lngLat","flyTo","duration","opts","styleType","inDarkMode","useInDarkMode"],"version":3,"file":"map-interface.eb663cae.js.map","sourceRoot":"../../../../"}
|