@macrostrat/map-interface 1.3.2 → 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.
Files changed (61) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/index.js +4 -4
  3. package/dist/cjs/{map-interface.3934d6d6.js → map-interface.10d442f4.js} +2 -2
  4. package/dist/cjs/{map-interface.3934d6d6.js.map → map-interface.10d442f4.js.map} +1 -1
  5. package/dist/cjs/{map-interface.f1eec151.js → map-interface.28d1a6b7.js} +7 -6
  6. package/dist/cjs/map-interface.28d1a6b7.js.map +1 -0
  7. package/dist/cjs/{map-interface.853e0edd.js → map-interface.3bc4f731.js} +2 -2
  8. package/dist/cjs/{map-interface.853e0edd.js.map → map-interface.3bc4f731.js.map} +1 -1
  9. package/dist/cjs/{map-interface.e7194f92.js → map-interface.7bdbe4b6.js} +59 -47
  10. package/dist/cjs/map-interface.7bdbe4b6.js.map +1 -0
  11. package/dist/cjs/{map-interface.5813e876.js → map-interface.cf6c9a68.js} +5 -5
  12. package/dist/cjs/{map-interface.5813e876.js.map → map-interface.cf6c9a68.js.map} +1 -1
  13. package/dist/cjs/{map-interface.1d19056e.js → map-interface.dcbd3874.js} +4 -2
  14. package/dist/cjs/map-interface.dcbd3874.js.map +1 -0
  15. package/dist/esm/index.d.ts +18 -29
  16. package/dist/esm/index.d.ts.map +1 -1
  17. package/dist/esm/index.js +4 -4
  18. package/dist/esm/{map-interface.e5349e97.js → map-interface.54ccd41f.js} +2 -2
  19. package/dist/esm/{map-interface.e5349e97.js.map → map-interface.54ccd41f.js.map} +1 -1
  20. package/dist/esm/{map-interface.25a708b1.js → map-interface.90d9023c.js} +2 -2
  21. package/dist/esm/{map-interface.25a708b1.js.map → map-interface.90d9023c.js.map} +1 -1
  22. package/dist/esm/{map-interface.9ce3d553.js → map-interface.ca1ee406.js} +61 -49
  23. package/dist/esm/map-interface.ca1ee406.js.map +1 -0
  24. package/dist/esm/{map-interface.e1493866.js → map-interface.e20a9bac.js} +4 -2
  25. package/dist/esm/map-interface.e20a9bac.js.map +1 -0
  26. package/dist/esm/{map-interface.f4e2f84e.js → map-interface.ec2278ab.js} +7 -6
  27. package/dist/esm/map-interface.ec2278ab.js.map +1 -0
  28. package/dist/esm/{map-interface.45814073.js → map-interface.f7b8bdb7.js} +5 -5
  29. package/dist/esm/{map-interface.45814073.js.map → map-interface.f7b8bdb7.js.map} +1 -1
  30. package/dist/node/index.js +1 -1
  31. package/dist/node/index.js.map +1 -1
  32. package/dist/node/map-interface.0dc4417b.js +2 -0
  33. package/dist/node/map-interface.0dc4417b.js.map +1 -0
  34. package/dist/node/{map-interface.eb663cae.js → map-interface.33b7734a.js} +2 -2
  35. package/dist/node/map-interface.33b7734a.js.map +1 -0
  36. package/dist/node/map-interface.56b5b2ee.js +2 -0
  37. package/dist/node/map-interface.56b5b2ee.js.map +1 -0
  38. package/dist/node/{map-interface.cf540298.js → map-interface.6184dc0f.js} +2 -2
  39. package/dist/node/{map-interface.cf540298.js.map → map-interface.6184dc0f.js.map} +1 -1
  40. package/dist/node/map-interface.7295b0a2.js +2 -0
  41. package/dist/node/map-interface.7295b0a2.js.map +1 -0
  42. package/dist/node/{map-interface.55fa679c.js → map-interface.f3e12e03.js} +2 -2
  43. package/dist/node/{map-interface.55fa679c.js.map → map-interface.f3e12e03.js.map} +1 -1
  44. package/package.json +3 -3
  45. package/src/dev/map-page.ts +25 -19
  46. package/src/helpers.ts +4 -4
  47. package/src/location-panel/header.ts +2 -5
  48. package/src/map-view.ts +77 -52
  49. package/dist/cjs/map-interface.1d19056e.js.map +0 -1
  50. package/dist/cjs/map-interface.e7194f92.js.map +0 -1
  51. package/dist/cjs/map-interface.f1eec151.js.map +0 -1
  52. package/dist/esm/map-interface.9ce3d553.js.map +0 -1
  53. package/dist/esm/map-interface.e1493866.js.map +0 -1
  54. package/dist/esm/map-interface.f4e2f84e.js.map +0 -1
  55. package/dist/node/map-interface.20c346ba.js +0 -2
  56. package/dist/node/map-interface.20c346ba.js.map +0 -1
  57. package/dist/node/map-interface.bc0fb98b.js +0 -2
  58. package/dist/node/map-interface.bc0fb98b.js.map +0 -1
  59. package/dist/node/map-interface.d9814996.js +0 -2
  60. package/dist/node/map-interface.d9814996.js.map +0 -1
  61. package/dist/node/map-interface.eb663cae.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format
4
4
  is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
5
5
  project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.4.0] - 2025-07-02
8
+
9
+ - Allow `DevMapPage` to set more options for the map, inherited from Mapbox GL
10
+ map options
11
+ - Streamline map position management during initialization
12
+ - Fix stuck loading spinner at map initialization
13
+ - Add new stories for position management
14
+ - Make `enableTerrain: false` work correctly
15
+ - Improve options for map view styling, by allowing the `className` to be set
16
+ and deprecating the auto setting of `#map` ID on the map view.
17
+
7
18
  ## [1.3.2] - 2025-06-26
8
19
 
9
20
  Bugfix for DevMapPage when applying custom styles
package/dist/cjs/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var $fce5fc950d1fe35b$exports = require("./map-interface.0e252a74.js");
2
- var $2bc7c1e4e7da7fdf$exports = require("./map-interface.3934d6d6.js");
3
- var $9acbb47bf7cb7660$exports = require("./map-interface.853e0edd.js");
2
+ var $2bc7c1e4e7da7fdf$exports = require("./map-interface.10d442f4.js");
3
+ var $9acbb47bf7cb7660$exports = require("./map-interface.3bc4f731.js");
4
4
  var $c3311f59335df34d$exports = require("./map-interface.bda26b27.js");
5
- var $493deb9ab6b848e3$exports = require("./map-interface.e7194f92.js");
5
+ var $493deb9ab6b848e3$exports = require("./map-interface.7bdbe4b6.js");
6
6
  var $f333fe6f49373ca9$exports = require("./map-interface.99a048dc.js");
7
- var $2611a7b4364593e5$exports = require("./map-interface.5813e876.js");
7
+ var $2611a7b4364593e5$exports = require("./map-interface.cf6c9a68.js");
8
8
  var $3490fc4f4bda12f7$exports = require("./map-interface.ffb109ef.js");
9
9
  var $860d9939f7032c69$exports = require("./map-interface.64823b7c.js");
10
10
  var $750d69d73bfbdc9a$exports = require("./map-interface.354aaa39.js");
@@ -1,4 +1,4 @@
1
- var $548387e5996cdbbd$exports = require("./map-interface.1d19056e.js");
1
+ var $548387e5996cdbbd$exports = require("./map-interface.dcbd3874.js");
2
2
  require("./map-interface.1b386e07.css");
3
3
  var $a8d7c4c397e52cf6$exports = require("./map-interface.cd485bb4.js");
4
4
  var $c3311f59335df34d$exports = require("./map-interface.bda26b27.js");
@@ -63,4 +63,4 @@ function $2bc7c1e4e7da7fdf$export$aa4baff5242ea6e1(props) {
63
63
  }
64
64
 
65
65
 
66
- //# sourceMappingURL=map-interface.3934d6d6.js.map
66
+ //# sourceMappingURL=map-interface.10d442f4.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAErB,SAAS,0CAAoB,KAAK;IACvC,MAAM,YAAY,CAAA,GAAA,2CAAS,EAAE,cAAc,MAAM,SAAS;IAC1D,OAAO,wBAAE,CAAA,GAAA,mCAAQ,GAAG;QAAE,GAAG,KAAK;mBAAE;IAAU;AAC5C;AAYO,SAAS,0CAAe,KAA0B;IACvD,MAAM,aACJ,SAAS,iBACT,gBAAgB,aAChB,KAAK,WACL,OAAO,YACP,QAAQ,oBACR,mBAAmB,2BACnB,GAAG,MACJ,GAAG;IACJ,MAAM,SACJ,iBACA,wBAAE,CAAA,GAAA,0CAAe,GAAG;iBAAE;QAAS,GAAG,IAAI;IAAC,GAAG;QACxC,SAAS,OAAO,OAAO,wBAAE,MAAM;YAAC;SAAM;KACvC;IACH,OAAO,wBAAE,2CAAqB;mBAAE;IAAU,GAAG;QAC3C;QACA,wBAAE,uBAAuB,wBAAE,CAAA,GAAA,2CAAY,GAAG,wBAAE,kBAAkB;KAC/D;AACH;AAEO,MAAM,4CAAe;AAErB,SAAS,0CAAc,KAAK;IACjC,MAAM,YAAE,QAAQ,aAAE,SAAS,WAAE,UAAU,OAAO,GAAG,MAAM,GAAG;IAC1D,MAAM,MAAM,CAAA,GAAA,2CAAS,EAAE,kBAAkB,WAAW;iBAAE;IAAQ;IAC9D,OAAO,wBAAE,2CAAgB;QAAE,WAAW;QAAK,GAAG,IAAI;IAAC,GAAG;AACxD","sources":["packages/map-interface/src/location-panel/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { InfoDrawerHeader, InfoDrawerHeaderProps } from \"./header\";\nimport classNames from \"classnames\";\nimport styles from \"./main.module.sass\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PanelCard } from \"../container\";\nimport { ComponentType } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport function InfoDrawerContainer(props) {\n const className = classNames(\"infodrawer\", props.className);\n return h(PanelCard, { ...props, className });\n}\n\ntype Component = string | ComponentType<any>;\n\ninterface BaseInfoDrawerProps extends InfoDrawerHeaderProps {\n className?: string;\n title?: string;\n headerElement?: JSX.Element;\n children?: React.ReactNode;\n contentContainer?: Component;\n}\n\nexport function BaseInfoDrawer(props: BaseInfoDrawerProps) {\n const {\n className,\n headerElement = null,\n title,\n onClose,\n children,\n contentContainer = \"div.infodrawer-contents\",\n ...rest\n } = props;\n const header =\n headerElement ??\n h(InfoDrawerHeader, { onClose, ...rest }, [\n title == null ? null : h(\"h3\", [title]),\n ]);\n return h(InfoDrawerContainer, { className }, [\n header,\n h(\"div.infodrawer-body\", h(ErrorBoundary, h(contentContainer, children))),\n ]);\n}\n\nexport const DetailsPanel = BaseInfoDrawer;\n\nexport function LocationPanel(props) {\n const { children, className, loading = false, ...rest } = props;\n const cls = classNames(\"location-panel\", className, { loading });\n return h(BaseInfoDrawer, { className: cls, ...rest }, children);\n}\n"],"names":[],"version":3,"file":"map-interface.3934d6d6.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAErB,SAAS,0CAAoB,KAAK;IACvC,MAAM,YAAY,CAAA,GAAA,2CAAS,EAAE,cAAc,MAAM,SAAS;IAC1D,OAAO,wBAAE,CAAA,GAAA,mCAAQ,GAAG;QAAE,GAAG,KAAK;mBAAE;IAAU;AAC5C;AAYO,SAAS,0CAAe,KAA0B;IACvD,MAAM,aACJ,SAAS,iBACT,gBAAgB,aAChB,KAAK,WACL,OAAO,YACP,QAAQ,oBACR,mBAAmB,2BACnB,GAAG,MACJ,GAAG;IACJ,MAAM,SACJ,iBACA,wBAAE,CAAA,GAAA,0CAAe,GAAG;iBAAE;QAAS,GAAG,IAAI;IAAC,GAAG;QACxC,SAAS,OAAO,OAAO,wBAAE,MAAM;YAAC;SAAM;KACvC;IACH,OAAO,wBAAE,2CAAqB;mBAAE;IAAU,GAAG;QAC3C;QACA,wBAAE,uBAAuB,wBAAE,CAAA,GAAA,2CAAY,GAAG,wBAAE,kBAAkB;KAC/D;AACH;AAEO,MAAM,4CAAe;AAErB,SAAS,0CAAc,KAAK;IACjC,MAAM,YAAE,QAAQ,aAAE,SAAS,WAAE,UAAU,OAAO,GAAG,MAAM,GAAG;IAC1D,MAAM,MAAM,CAAA,GAAA,2CAAS,EAAE,kBAAkB,WAAW;iBAAE;IAAQ;IAC9D,OAAO,wBAAE,2CAAgB;QAAE,WAAW;QAAK,GAAG,IAAI;IAAC,GAAG;AACxD","sources":["packages/map-interface/src/location-panel/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { InfoDrawerHeader, InfoDrawerHeaderProps } from \"./header\";\nimport classNames from \"classnames\";\nimport styles from \"./main.module.sass\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { PanelCard } from \"../container\";\nimport { ComponentType } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport function InfoDrawerContainer(props) {\n const className = classNames(\"infodrawer\", props.className);\n return h(PanelCard, { ...props, className });\n}\n\ntype Component = string | ComponentType<any>;\n\ninterface BaseInfoDrawerProps extends InfoDrawerHeaderProps {\n className?: string;\n title?: string;\n headerElement?: JSX.Element;\n children?: React.ReactNode;\n contentContainer?: Component;\n}\n\nexport function BaseInfoDrawer(props: BaseInfoDrawerProps) {\n const {\n className,\n headerElement = null,\n title,\n onClose,\n children,\n contentContainer = \"div.infodrawer-contents\",\n ...rest\n } = props;\n const header =\n headerElement ??\n h(InfoDrawerHeader, { onClose, ...rest }, [\n title == null ? null : h(\"h3\", [title]),\n ]);\n return h(InfoDrawerContainer, { className }, [\n header,\n h(\"div.infodrawer-body\", h(ErrorBoundary, h(contentContainer, children))),\n ]);\n}\n\nexport const DetailsPanel = BaseInfoDrawer;\n\nexport function LocationPanel(props) {\n const { children, className, loading = false, ...rest } = props;\n const cls = classNames(\"location-panel\", className, { loading });\n return h(BaseInfoDrawer, { className: cls, ...rest }, children);\n}\n"],"names":[],"version":3,"file":"map-interface.10d442f4.js.map"}
@@ -1,9 +1,9 @@
1
1
  var $8646508ae99a5857$exports = require("./map-interface.4c5addca.js");
2
2
  var $c3311f59335df34d$exports = require("./map-interface.bda26b27.js");
3
3
  var $fce5fc950d1fe35b$exports = require("./map-interface.0e252a74.js");
4
- var $2611a7b4364593e5$exports = require("./map-interface.5813e876.js");
5
- var $2bc7c1e4e7da7fdf$exports = require("./map-interface.3934d6d6.js");
6
- var $493deb9ab6b848e3$exports = require("./map-interface.e7194f92.js");
4
+ var $2611a7b4364593e5$exports = require("./map-interface.cf6c9a68.js");
5
+ var $2bc7c1e4e7da7fdf$exports = require("./map-interface.10d442f4.js");
6
+ var $493deb9ab6b848e3$exports = require("./map-interface.7bdbe4b6.js");
7
7
  var $33088e8384af337c$exports = require("./map-interface.abe5fe65.js");
8
8
  require("./map-interface.26497065.css");
9
9
  var $abbe8d0af34cbbed$exports = require("./map-interface.f8826069.js");
@@ -42,7 +42,7 @@ $parcel$export(module.exports, "DevMapPage", () => $6f5ca387ac26c0b5$export$2391
42
42
 
43
43
 
44
44
  const $6f5ca387ac26c0b5$export$dda1d9f60106f0e9 = (0, ($parcel$interopDefault($g1A1s$macrostrathyper))).styled((0, ($parcel$interopDefault($33088e8384af337c$exports))));
45
- function $6f5ca387ac26c0b5$export$eab3034e57b46e26({ title: title = "Map inspector", headerElement: headerElement = null, transformRequest: transformRequest = null, mapPosition: mapPosition = null, mapboxToken: mapboxToken = null, overlayStyle: overlayStyle = null, controls: controls = null, children: children = null, style: style, bounds: bounds = null, focusedSource: focusedSource = null, focusedSourceTitle: focusedSourceTitle = null, fitViewport: fitViewport = true, styleType: styleType = "macrostrat" }) {
45
+ function $6f5ca387ac26c0b5$export$eab3034e57b46e26({ title: title = "Map inspector", headerElement: headerElement = null, transformRequest: transformRequest = null, mapPosition: mapPosition = null, mapboxToken: mapboxToken = null, overlayStyle: overlayStyle = null, controls: controls = null, children: children = null, style: style, bounds: bounds = null, focusedSource: focusedSource = null, focusedSourceTitle: focusedSourceTitle = null, fitViewport: fitViewport = true, styleType: styleType = "macrostrat", ...rest }) {
46
46
  /* We apply a custom style to the panel container when we are interacting
47
47
  with the search bar, so that we can block map interactions until search
48
48
  bar focus is lost.
@@ -149,7 +149,8 @@ function $6f5ca387ac26c0b5$export$eab3034e57b46e26({ title: title = "Map inspect
149
149
  name: "globe"
150
150
  },
151
151
  mapboxToken: mapboxToken,
152
- bounds: bounds
152
+ bounds: bounds,
153
+ ...rest
153
154
  }, [
154
155
  $6f5ca387ac26c0b5$export$dda1d9f60106f0e9((0, $db14eb7a5c07abdb$exports.FeatureSelectionHandler), {
155
156
  selectedLocation: inspectPosition,
@@ -181,4 +182,4 @@ function $6f5ca387ac26c0b5$var$MapInspector(props) {
181
182
  const $6f5ca387ac26c0b5$export$2391061fbdfb71ef = $6f5ca387ac26c0b5$var$MapInspector;
182
183
 
183
184
 
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AAQ;qBAC5B;gBACA;QACA,GAAG,IAAI;IACT,GACA;QACE,0CAAE,CAAA,GAAA,iDAAsB,GAAG;YACzB,kBAAkB;YAClB,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,mCAAQ,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 { useDarkMode, useStoredState } from \"@macrostrat/ui-components\";\nimport mapboxgl from \"mapbox-gl\";\nimport React from \"react\";\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, MapViewProps } 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\ninterface MapInspectorProps extends MapViewProps {\n headerElement?: React.ReactNode;\n transformRequest?: mapboxgl.RequestTransformFunction;\n title?: string;\n style?: mapboxgl.StyleSpecification | string;\n controls?: React.ReactNode;\n children?: React.ReactNode;\n mapboxToken?: string;\n overlayStyle?: mapboxgl.StyleSpecification | 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 enableTerrain?: boolean;\n}\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 ...rest\n}: MapInspectorProps) {\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 ...rest,\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.28d1a6b7.js.map"}
@@ -1,4 +1,4 @@
1
- var $6f5ca387ac26c0b5$exports = require("./map-interface.f1eec151.js");
1
+ var $6f5ca387ac26c0b5$exports = require("./map-interface.28d1a6b7.js");
2
2
  var $abbe8d0af34cbbed$exports = require("./map-interface.f8826069.js");
3
3
  var $db14eb7a5c07abdb$exports = require("./map-interface.e9bcd5c0.js");
4
4
  var $8646508ae99a5857$exports = require("./map-interface.4c5addca.js");
@@ -30,4 +30,4 @@ $parcel$exportWildcard(module.exports, $db14eb7a5c07abdb$exports);
30
30
  $parcel$exportWildcard(module.exports, $8646508ae99a5857$exports);
31
31
 
32
32
 
33
- //# sourceMappingURL=map-interface.853e0edd.js.map
33
+ //# sourceMappingURL=map-interface.3bc4f731.js.map
@@ -1 +1 @@
1
- {"mappings":"","sources":["packages/map-interface/src/dev/index.ts"],"sourcesContent":["export * from \"./map-page\";\nexport * from \"./tile-extent\";\nexport * from \"./vector-tile-features\";\nexport * from \"./xray\";\n"],"names":[],"version":3,"file":"map-interface.853e0edd.js.map"}
1
+ {"mappings":"","sources":["packages/map-interface/src/dev/index.ts"],"sourcesContent":["export * from \"./map-page\";\nexport * from \"./tile-extent\";\nexport * from \"./vector-tile-features\";\nexport * from \"./xray\";\n"],"names":[],"version":3,"file":"map-interface.3bc4f731.js.map"}
@@ -1,6 +1,6 @@
1
1
  var $35f1bc0112883d51$exports = require("./map-interface.a9fe0f5d.js");
2
2
  require("./map-interface.4a401c1f.css");
3
- var $2611a7b4364593e5$exports = require("./map-interface.5813e876.js");
3
+ var $2611a7b4364593e5$exports = require("./map-interface.cf6c9a68.js");
4
4
  var $3490fc4f4bda12f7$exports = require("./map-interface.ffb109ef.js");
5
5
  var $8GJXj$macrostrathyper = require("@macrostrat/hyper");
6
6
  var $8GJXj$macrostratmapboxreact = require("@macrostrat/mapbox-react");
@@ -40,7 +40,7 @@ function $493deb9ab6b848e3$var$defaultInitializeMap(container, args = {}) {
40
40
  container: container,
41
41
  maxZoom: 18,
42
42
  logoPosition: "bottom-left",
43
- trackResize: true,
43
+ trackResize: false,
44
44
  antialias: true,
45
45
  // This is a legacy option for Mapbox GL v2
46
46
  // @ts-ignore
@@ -64,8 +64,16 @@ const $493deb9ab6b848e3$var$defaultMapPosition = {
64
64
  function $493deb9ab6b848e3$export$ab1e7a67d6ec5ad8(props) {
65
65
  let { terrainSourceID: terrainSourceID } = props;
66
66
  const { enableTerrain: enableTerrain = true, style: style, mapPosition: mapPosition, initializeMap: initializeMap = $493deb9ab6b848e3$var$defaultInitializeMap, children: children, mapboxToken: mapboxToken, accessToken: // Deprecated
67
- 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;
67
+ accessToken, infoMarkerPosition: infoMarkerPosition, transformRequest: transformRequest, projection: projection, onMapLoaded: onMapLoaded = null, onStyleLoaded: onStyleLoaded = null, onMapMoved: onMapMoved = null, standalone: standalone = false, overlayStyles: overlayStyles, transformStyle: transformStyle, trackResize: trackResize = true, loadingIgnoredSources: loadingIgnoredSources = [
68
+ "elevationMarker",
69
+ "crossSectionEndpoints"
70
+ ], id: id = "map", className: className, ...rest } = props;
68
71
  if (enableTerrain) terrainSourceID ??= "mapbox-3d-dem";
72
+ (0, $8GJXj$react.useEffect)(()=>{
73
+ if (id != null) console.warn("Setting a specific element ID for the map is deprecated. Please use className instead.");
74
+ }, [
75
+ id
76
+ ]);
69
77
  const _mapboxToken = mapboxToken ?? accessToken;
70
78
  if (_mapboxToken != null) (0, ($parcel$interopDefault($8GJXj$mapboxgl))).accessToken = _mapboxToken;
71
79
  const dispatch = (0, $8GJXj$macrostratmapboxreact.useMapDispatch)();
@@ -73,37 +81,34 @@ function $493deb9ab6b848e3$export$ab1e7a67d6ec5ad8(props) {
73
81
  const ref = (0, $8GJXj$react.useRef)();
74
82
  const parentRef = (0, $8GJXj$react.useRef)();
75
83
  const [baseStyle, setBaseStyle] = (0, $8GJXj$react.useState)(null);
76
- const isStyleLoaded = (0, $8GJXj$macrostratmapboxreact.useMapStatus)((state)=>state.isStyleLoaded);
84
+ const estMapPosition = mapRef.current == null ? mapPosition : (0, $8GJXj$macrostratmapboxutils.getMapPosition)(mapRef.current);
85
+ const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $8GJXj$macrostratmapboxutils.mapViewInfo)(estMapPosition);
86
+ const is3DAvailable = (mapUse3D ?? false) && enableTerrain;
77
87
  (0, $8GJXj$react.useEffect)(()=>{
78
88
  /** Manager to update map style */ if (baseStyle == null) return;
79
89
  let map = mapRef.current;
90
+ let newStyle = baseStyle;
91
+ const overlayStyles = props.overlayStyles ?? [];
92
+ if (overlayStyles.length > 0) newStyle = (0, $8GJXj$macrostratmapboxutils.mergeStyles)(newStyle, ...overlayStyles);
80
93
  /** If we can, we try to update the map style with terrain information
81
94
  * immediately, before the style is loaded. This allows us to avoid a
82
95
  * flash of the map without terrain.
83
96
  *
84
97
  * To do this, we need to estimate the map position before load, which
85
98
  * doesn't always work.
86
- */ // We either get the map position directly from the map or from props
87
- const estMapPosition = map == null ? mapPosition : (0, $8GJXj$macrostratmapboxutils.getMapPosition)(map);
88
- const { mapUse3D: mapUse3D } = (0, $8GJXj$macrostratmapboxutils.mapViewInfo)(estMapPosition);
89
- let newStyle = baseStyle;
90
- const overlayStyles = props.overlayStyles ?? [];
91
- if (overlayStyles.length > 0) newStyle = (0, $8GJXj$macrostratmapboxutils.mergeStyles)(newStyle, ...overlayStyles);
92
- if (mapUse3D) {
99
+ */ if (is3DAvailable) {
93
100
  // We can update the style with terrain layers immediately
94
101
  const terrainStyle = (0, $8GJXj$macrostratmapboxreact.getTerrainLayerForStyle)(newStyle, terrainSourceID);
95
102
  newStyle = (0, $8GJXj$macrostratmapboxutils.mergeStyles)(newStyle, terrainStyle);
96
103
  }
97
104
  if (transformStyle != null) newStyle = transformStyle(newStyle);
98
105
  if (map != null) {
99
- console.log("Setting style", newStyle);
100
106
  dispatch({
101
107
  type: "set-style-loaded",
102
108
  payload: false
103
109
  });
104
110
  map.setStyle(newStyle);
105
111
  } else {
106
- console.log("Initializing map", newStyle);
107
112
  const map = initializeMap(ref.current, {
108
113
  style: newStyle,
109
114
  projection: projection,
@@ -125,26 +130,6 @@ function $493deb9ab6b848e3$export$ab1e7a67d6ec5ad8(props) {
125
130
  overlayStyles,
126
131
  transformStyle
127
132
  ]);
128
- /** Check back every 0.1 seconds to see if the map has loaded.
129
- * We do it this way because mapboxgl loading events are unreliable */ (0, $8GJXj$react.useEffect)(()=>{
130
- if (isStyleLoaded) return;
131
- const interval = setInterval(()=>{
132
- const map = mapRef.current;
133
- if (map == null) return;
134
- if (map.isStyleLoaded()) {
135
- // Wait a tick before setting the style loaded state
136
- dispatch({
137
- type: "set-style-loaded",
138
- payload: true
139
- });
140
- onStyleLoaded?.(map);
141
- clearInterval(interval);
142
- }
143
- }, 50);
144
- return ()=>clearInterval(interval);
145
- }, [
146
- isStyleLoaded
147
- ]);
148
133
  (0, $8GJXj$macrostratuicomponents.useAsyncEffect)(async ()=>{
149
134
  /** Manager to update map style */ let newStyle;
150
135
  if (typeof style === "string") newStyle = await (0, $8GJXj$macrostratmapboxutils.getMapboxStyle)(style, {
@@ -155,35 +140,36 @@ function $493deb9ab6b848e3$export$ab1e7a67d6ec5ad8(props) {
155
140
  }, [
156
141
  style
157
142
  ]);
158
- const _computedMapPosition = (0, $8GJXj$macrostratmapboxreact.useMapPosition)();
159
- const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $8GJXj$macrostratmapboxutils.mapViewInfo)(_computedMapPosition);
160
143
  // Get map projection
161
144
  const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
162
- const className = (0, ($parcel$interopDefault($8GJXj$classnames)))({
145
+ const mapClassName = (0, ($parcel$interopDefault($8GJXj$classnames)))({
163
146
  "is-rotated": mapIsRotated ?? false,
164
- "is-3d-available": mapUse3D ?? false
147
+ "is-3d-available": is3DAvailable
165
148
  }, `${_projection}-projection`);
166
149
  const parentClassName = (0, ($parcel$interopDefault($8GJXj$classnames)))({
167
150
  standalone: standalone
168
- });
151
+ }, className);
169
152
  return $493deb9ab6b848e3$var$h("div.map-view-container.main-view", {
170
153
  ref: parentRef,
171
154
  className: parentClassName
172
155
  }, [
173
- $493deb9ab6b848e3$var$h("div.mapbox-map#map", {
156
+ $493deb9ab6b848e3$var$h("div.mapbox-map.map-view", {
174
157
  ref: ref,
175
- className: className
158
+ className: mapClassName,
159
+ id: id
176
160
  }),
177
161
  $493deb9ab6b848e3$var$h((0, $2611a7b4364593e5$exports.MapLoadingReporter), {
178
- ignoredSources: [
179
- "elevationMarker",
180
- "crossSectionEndpoints"
181
- ]
162
+ ignoredSources: loadingIgnoredSources
163
+ }),
164
+ $493deb9ab6b848e3$var$h($493deb9ab6b848e3$var$StyleLoadedReporter, {
165
+ onStyleLoaded: onStyleLoaded
182
166
  }),
183
167
  $493deb9ab6b848e3$var$h((0, $2611a7b4364593e5$exports.MapMovedReporter), {
184
168
  onMapMoved: onMapMoved
185
169
  }),
186
- $493deb9ab6b848e3$var$h((0, $2611a7b4364593e5$exports.MapResizeManager), {
170
+ // Subsitute for trackResize: true that allows map resizing to
171
+ // be tied to a specific ref component
172
+ $493deb9ab6b848e3$var$h.if(trackResize)((0, $2611a7b4364593e5$exports.MapResizeManager), {
187
173
  containerRef: ref
188
174
  }),
189
175
  $493deb9ab6b848e3$var$h((0, $2611a7b4364593e5$exports.MapPaddingManager), {
@@ -192,17 +178,43 @@ function $493deb9ab6b848e3$export$ab1e7a67d6ec5ad8(props) {
192
178
  infoMarkerPosition: infoMarkerPosition
193
179
  }),
194
180
  $493deb9ab6b848e3$var$h($493deb9ab6b848e3$export$cee395a8a2a00b29, {
195
- mapUse3D: mapUse3D,
181
+ mapUse3D: is3DAvailable,
196
182
  terrainSourceID: terrainSourceID,
197
183
  style: style
198
184
  }),
199
185
  children
200
186
  ]);
201
187
  }
188
+ function $493deb9ab6b848e3$var$StyleLoadedReporter({ onStyleLoaded: onStyleLoaded = null }) {
189
+ /** Check back every 0.1 seconds to see if the map has loaded.
190
+ * We do it this way because mapboxgl loading events are unreliable */ const isStyleLoaded = (0, $8GJXj$macrostratmapboxreact.useMapStatus)((state)=>state.isStyleLoaded);
191
+ const mapRef = (0, $8GJXj$macrostratmapboxreact.useMapRef)();
192
+ const dispatch = (0, $8GJXj$macrostratmapboxreact.useMapDispatch)();
193
+ (0, $8GJXj$react.useEffect)(()=>{
194
+ if (isStyleLoaded) return;
195
+ const interval = setInterval(()=>{
196
+ const map = mapRef.current;
197
+ if (map == null) return;
198
+ if (map.isStyleLoaded()) {
199
+ // Wait a tick before setting the style loaded state
200
+ dispatch({
201
+ type: "set-style-loaded",
202
+ payload: true
203
+ });
204
+ onStyleLoaded?.(map);
205
+ clearInterval(interval);
206
+ }
207
+ }, 50);
208
+ return ()=>clearInterval(interval);
209
+ }, [
210
+ isStyleLoaded
211
+ ]);
212
+ return null;
213
+ }
202
214
  function $493deb9ab6b848e3$export$cee395a8a2a00b29({ mapUse3D: mapUse3D, terrainSourceID: terrainSourceID, style: style }) {
203
215
  (0, $8GJXj$macrostratmapboxreact.use3DTerrain)(mapUse3D, terrainSourceID);
204
216
  return null;
205
217
  }
206
218
 
207
219
 
208
- //# sourceMappingURL=map-interface.e7194f92.js.map
220
+ //# sourceMappingURL=map-interface.7bdbe4b6.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAwC5B,SAAS,2CAAqB,SAAS,EAAE,OAAyB,CAAC,CAAC;IAClE,MAAM,eAAE,WAAW,EAAE,GAAG,MAAM,GAAG;IAEjC,MAAM,MAAM,IAAI,CAAA,GAAA,yCAAO,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,oE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["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-react\";\nimport React from \"react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt,\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.StyleSpecification>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (\n style: mapboxgl.StyleSpecification,\n ) => mapboxgl.StyleSpecification;\n loadingIgnoredSources?: string[];\n id?: string;\n className?: string;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: false,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n trackResize = true,\n loadingIgnoredSources = [\"elevationMarker\", \"crossSectionEndpoints\"],\n id = \"map\",\n className,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n useEffect(() => {\n if (id != null) {\n console.warn(\n \"Setting a specific element ID for the map is deprecated. Please use className instead.\",\n );\n }\n }, [id]);\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n\n const estMapPosition: MapPosition | null =\n mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);\n const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);\n const is3DAvailable = (mapUse3D ?? false) && enableTerrain;\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n let newStyle: mapboxgl.StyleSpecification = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n if (is3DAvailable) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, transformStyle]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.StyleSpecification;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const mapClassName = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": is3DAvailable,\n },\n `${_projection}-projection`,\n );\n\n const parentClassName = classNames(\n {\n standalone,\n },\n className,\n );\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map.map-view\", { ref, className: mapClassName, id }),\n h(MapLoadingReporter, {\n ignoredSources: loadingIgnoredSources,\n }),\n h(StyleLoadedReporter, { onStyleLoaded }),\n h(MapMovedReporter, { onMapMoved }),\n // Subsitute for trackResize: true that allows map resizing to\n // be tied to a specific ref component\n h.if(trackResize)(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D: is3DAvailable, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nfunction StyleLoadedReporter({ onStyleLoaded = null }) {\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n const mapRef = useMapRef();\n const dispatch = useMapDispatch();\n\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n return null;\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.StyleSpecification | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.7bdbe4b6.js.map"}
@@ -123,20 +123,20 @@ function $2611a7b4364593e5$export$e57f9eaa51773f82({ ignoredSources: ignoredSour
123
123
  const map = mapRef.current;
124
124
  const mapIsLoading = loadingRef.current;
125
125
  if (map == null) return;
126
- let didSendLoading = false;
126
+ //let didSendLoading = false;
127
127
  const loadingCallback = (evt)=>{
128
128
  if (ignoredSources.includes(evt.sourceId) || mapIsLoading) return;
129
- if (didSendLoading) return;
129
+ //if (didSendLoading) return;
130
130
  onMapLoading?.(evt);
131
131
  dispatch({
132
132
  type: "set-loading",
133
133
  payload: true
134
134
  });
135
135
  loadingRef.current = true;
136
- didSendLoading = true;
136
+ //didSendLoading = true;
137
137
  };
138
138
  const idleCallback = (evt)=>{
139
- if (!mapIsLoading) return;
139
+ if (!map.loaded()) return;
140
140
  dispatch({
141
141
  type: "set-loading",
142
142
  payload: false
@@ -205,4 +205,4 @@ function $2611a7b4364593e5$export$3503bf0b3851527b(opts) {
205
205
  const $2611a7b4364593e5$export$566518253d2584f8 = $2611a7b4364593e5$export$6daf1520df36ae21;
206
206
 
207
207
 
208
- //# sourceMappingURL=map-interface.5813e876.js.map
208
+ //# sourceMappingURL=map-interface.cf6c9a68.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,SAAS,0CAAiB,gBAAE,YAAY,EAAE;IAC/C,MAAM,SAAS,CAAA,GAAA,sCAAQ;IAEvB,MAAM,kBAAkB,CAAA,GAAA,mBAAK,EAC3B,CAAA,GAAA,0BAAO,EAAE;QACP,OAAO,OAAO,EAAE;IAClB,GAAG;IAGL,CAAA,GAAA,kDAAgB,EAAE;QAChB,KAAK;QACL,UAAU,gBAAgB,OAAO;IACnC;IAEA,OAAO;AACT;AASO,SAAS,0CAAkB,gBAChC,YAAY,aACZ,SAAS,sBACT,kBAAkB,gBAClB,eAAe,KACQ;IACvB,MAAM,SAAS,CAAA,GAAA,sCAAQ;IAEvB,MAAM,CAAC,SAAS,WAAW,GAAG,CAAA,GAAA,qBAAO,EACnC,CAAA,GAAA,uCAAY,EAAE,cAAc;IAG9B,MAAM,oBAAoB,CAAA,GAAA,wBAAU,EAAE;QACpC,MAAM,aAAa,CAAA,GAAA,uCAAY,EAAE,cAAc;QAC/C,WAAW;IACb,GAAG;QAAC,aAAa,OAAO;QAAE,UAAU,OAAO;KAAC;IAE5C,MAAM,mBAAmB,CAAA,GAAA,oBAAM,EAC7B,IAAM,CAAA,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,OAAO,EAAE,MAAM;gBAAE,QAAQ,MAAM,MAAM;gBAAE,UAAU;YAAI;QAEhE;QAEA,IAAI,EAAE,CAAC,SAAS;QAEhB,OAAO;YACL,KAAK,IAAI,SAAS;QACpB;IACF,GAAG;QAAC;QAAa;KAAc;IAE/B,OAAO;AACT;AAEO,SAAS,0CACd,OAEI,CAAC,CAAC;IAEN,MAAM,aAAE,SAAS,EAAE,GAAG;IACtB,MAAM,aAAa,CAAA,GAAA,2CAAY;IAE/B,MAAM,QAAQ,CAAA,GAAA,oBAAM,EAAE;QACpB,OAAO;uBAAE;wBAAW;QAAW;IACjC,GAAG;QAAC;QAAW;KAAW;IAE1B,OAAO,0CAAiB;AAC1B;AAEO,SAAS,0CAAiB,IAGhC;IACC,MAAM,aAAE,YAAY,0BAAc,aAAa,OAAO,GAAG,QAAQ,CAAC;IAElE,IAAI,aAAa,cACf,OAAO,aACH,wEACA;SAEJ,OAAO,aACH,oCACA;AAER;AAEO,MAAM,4CAAoB","sources":["packages/map-interface/src/helpers.ts"],"sourcesContent":["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":[],"version":3,"file":"map-interface.5813e876.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,SAAS,0CAAiB,gBAAE,YAAY,EAAE;IAC/C,MAAM,SAAS,CAAA,GAAA,sCAAQ;IAEvB,MAAM,kBAAkB,CAAA,GAAA,mBAAK,EAC3B,CAAA,GAAA,0BAAO,EAAE;QACP,OAAO,OAAO,EAAE;IAClB,GAAG;IAGL,CAAA,GAAA,kDAAgB,EAAE;QAChB,KAAK;QACL,UAAU,gBAAgB,OAAO;IACnC;IAEA,OAAO;AACT;AASO,SAAS,0CAAkB,gBAChC,YAAY,aACZ,SAAS,sBACT,kBAAkB,gBAClB,eAAe,KACQ;IACvB,MAAM,SAAS,CAAA,GAAA,sCAAQ;IAEvB,MAAM,CAAC,SAAS,WAAW,GAAG,CAAA,GAAA,qBAAO,EACnC,CAAA,GAAA,uCAAY,EAAE,cAAc;IAG9B,MAAM,oBAAoB,CAAA,GAAA,wBAAU,EAAE;QACpC,MAAM,aAAa,CAAA,GAAA,uCAAY,EAAE,cAAc;QAC/C,WAAW;IACb,GAAG;QAAC,aAAa,OAAO;QAAE,UAAU,OAAO;KAAC;IAE5C,MAAM,mBAAmB,CAAA,GAAA,oBAAM,EAC7B,IAAM,CAAA,GAAA,0BAAO,EAAE,mBAAmB,eAClC;QAAC;QAAmB;KAAa;IAGnC,CAAA,GAAA,sB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;QAEA,IAAI,EAAE,CAAC,SAAS;QAEhB,OAAO;YACL,KAAK,IAAI,SAAS;QACpB;IACF,GAAG;QAAC;QAAa;KAAc;IAE/B,OAAO;AACT;AAEO,SAAS,0CACd,OAEI,CAAC,CAAC;IAEN,MAAM,aAAE,SAAS,EAAE,GAAG;IACtB,MAAM,aAAa,CAAA,GAAA,2CAAY;IAE/B,MAAM,QAAQ,CAAA,GAAA,oBAAM,EAAE;QACpB,OAAO;uBAAE;wBAAW;QAAW;IACjC,GAAG;QAAC;QAAW;KAAW;IAE1B,OAAO,0CAAiB;AAC1B;AAEO,SAAS,0CAAiB,IAGhC;IACC,MAAM,aAAE,YAAY,0BAAc,aAAa,OAAO,GAAG,QAAQ,CAAC;IAElE,IAAI,aAAa,cACf,OAAO,aACH,wEACA;SAEJ,OAAO,aACH,oCACA;AAER;AAEO,MAAM,4CAAoB","sources":["packages/map-interface/src/helpers.ts"],"sourcesContent":["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 (!map.loaded()) 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":[],"version":3,"file":"map-interface.cf6c9a68.js.map"}
@@ -6,6 +6,7 @@ var $hshpw$macrostrathyper = require("@macrostrat/hyper");
6
6
  var $hshpw$macrostratuicomponents = require("@macrostrat/ui-components");
7
7
  var $hshpw$macrostratmapboxreact = require("@macrostrat/mapbox-react");
8
8
  var $hshpw$classnames = require("classnames");
9
+ var $hshpw$macrostratmapboxutils = require("@macrostrat/mapbox-utils");
9
10
 
10
11
 
11
12
  function $parcel$interopDefault(a) {
@@ -24,10 +25,11 @@ $parcel$export(module.exports, "InfoDrawerHeader", () => $548387e5996cdbbd$expor
24
25
 
25
26
 
26
27
 
28
+
27
29
  const $548387e5996cdbbd$var$h = (0, ($parcel$interopDefault($hshpw$macrostrathyper))).styled((0, ($parcel$interopDefault($a8d7c4c397e52cf6$exports))));
28
30
  function $548387e5996cdbbd$var$PositionButton({ position: position, bounds: bounds, showCopyLink: showCopyLink = false }) {
29
31
  const focusState = (0, $hshpw$macrostratmapboxreact.useFocusState)(position);
30
- const copyLinkIsVisible = (0, $hshpw$macrostratmapboxreact.isCentered)(focusState) && showCopyLink;
32
+ const copyLinkIsVisible = (0, $hshpw$macrostratmapboxutils.isCentered)(focusState) && showCopyLink;
31
33
  return $548387e5996cdbbd$var$h("div.position-controls", [
32
34
  $548387e5996cdbbd$var$h((0, $hshpw$macrostratmapboxreact.LocationFocusButton), {
33
35
  location: position,
@@ -107,4 +109,4 @@ function $548387e5996cdbbd$export$e9ff14c4822c2e8c(props) {
107
109
  }
108
110
 
109
111
 
110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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 { LocationFocusButton, useFocusState } from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\nimport type { ReactNode } from \"react\";\nimport type { LngLatBounds, LngLatLike } from \"mapbox-gl\";\nimport { isCentered } from \"@macrostrat/mapbox-utils\";\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.dcbd3874.js.map"}
@@ -1,4 +1,4 @@
1
- import { ReactNode, FunctionComponentElement, JSXElementConstructor, ReactElement, DOMAttributes, DOMElement, DetailedReactHTMLElement, ComponentType, MutableRefObject } from "react";
1
+ import React, { ReactNode, FunctionComponentElement, JSXElementConstructor, ReactElement, DOMAttributes, DOMElement, DetailedReactHTMLElement, ComponentType } from "react";
2
2
  import { ButtonProps, CardProps } from "@blueprintjs/core";
3
3
  import { ParsedQuery } from "query-string";
4
4
  import { LngLatBounds, LngLatLike, LightSpecification, LightsSpecification, TerrainSpecification, FogSpecification, SnowSpecification, RainSpecification, CameraSpecification, ColorThemeSpecification, IndoorSpecification, ImportSpecification, IconsetsSpecification, SchemaSpecification, SourcesSpecification, TransitionSpecification, ProjectionSpecification, ModelsSpecification, FeaturesetsSpecification, StyleSpecification } from "mapbox-gl";
@@ -233,21 +233,24 @@ export interface MapViewProps extends MapboxCoreOptions {
233
233
  standalone?: boolean;
234
234
  /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to
235
235
  * overlay on top of the main map style at runtime */
236
- overlayStyles?: Partial<mapboxgl.Style>[];
236
+ overlayStyles?: Partial<mapboxgl.StyleSpecification>[];
237
237
  /** A function to transform the map style before it is loaded */
238
- transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;
238
+ transformStyle?: (style: mapboxgl.StyleSpecification) => mapboxgl.StyleSpecification;
239
+ loadingIgnoredSources?: string[];
240
+ id?: string;
241
+ className?: string;
239
242
  }
240
243
  export interface MapboxOptionsExt extends MapboxCoreOptions {
241
244
  mapPosition?: MapPosition;
242
245
  }
243
- export function MapView(props: MapViewProps): ReactElement<{
244
- ref: MutableRefObject<HTMLDivElement>;
246
+ export function MapView(props: MapViewProps): React.ReactElement<{
247
+ ref: React.MutableRefObject<HTMLDivElement>;
245
248
  className: string;
246
- }, string | JSXElementConstructor<any>>;
249
+ }, string | React.JSXElementConstructor<any>>;
247
250
  export function MapTerrainManager({ mapUse3D, terrainSourceID, style, }: {
248
251
  mapUse3D?: boolean;
249
252
  terrainSourceID?: string;
250
- style?: mapboxgl.Style | string;
253
+ style?: mapboxgl.StyleSpecification | string;
251
254
  }): any;
252
255
  type TileIndex = {
253
256
  x: number;
@@ -305,15 +308,15 @@ export function Features({ features }: {
305
308
  features: any;
306
309
  }): DOMElement<any, Element>;
307
310
  export const h: Hyper;
308
- export function MapInspectorV2({ title, headerElement, transformRequest, mapPosition, mapboxToken, overlayStyle, controls, children, style, bounds, focusedSource, focusedSourceTitle, fitViewport, styleType, }: {
311
+ interface MapInspectorProps extends MapViewProps {
309
312
  headerElement?: React.ReactNode;
310
- transformRequest?: mapboxgl.TransformRequestFunction;
313
+ transformRequest?: mapboxgl.RequestTransformFunction;
311
314
  title?: string;
312
- style?: mapboxgl.Style | string;
315
+ style?: mapboxgl.StyleSpecification | string;
313
316
  controls?: React.ReactNode;
314
317
  children?: React.ReactNode;
315
318
  mapboxToken?: string;
316
- overlayStyle?: mapboxgl.Style | string;
319
+ overlayStyle?: mapboxgl.StyleSpecification | string;
317
320
  focusedSource?: string;
318
321
  focusedSourceTitle?: string;
319
322
  projection?: string;
@@ -321,24 +324,10 @@ export function MapInspectorV2({ title, headerElement, transformRequest, mapPosi
321
324
  bounds?: [number, number, number, number];
322
325
  fitViewport?: boolean;
323
326
  styleType?: "standard" | "macrostrat";
324
- }): FunctionComponentElement<any>;
325
- declare function MapInspector(props: any): FunctionComponentElement<{
326
- headerElement?: React.ReactNode;
327
- transformRequest?: mapboxgl.TransformRequestFunction;
328
- title?: string;
329
- style?: mapboxgl.Style | string;
330
- controls?: React.ReactNode;
331
- children?: React.ReactNode;
332
- mapboxToken?: string;
333
- overlayStyle?: mapboxgl.Style | string;
334
- focusedSource?: string;
335
- focusedSourceTitle?: string;
336
- projection?: string;
337
- mapPosition?: MapPosition;
338
- bounds?: [number, number, number, number];
339
- fitViewport?: boolean;
340
- styleType?: "standard" | "macrostrat";
341
- }>;
327
+ enableTerrain?: boolean;
328
+ }
329
+ export function MapInspectorV2({ title, headerElement, transformRequest, mapPosition, mapboxToken, overlayStyle, controls, children, style, bounds, focusedSource, focusedSourceTitle, fitViewport, styleType, ...rest }: MapInspectorProps): React.FunctionComponentElement<any>;
330
+ declare function MapInspector(props: any): React.FunctionComponentElement<MapInspectorProps>;
342
331
  export const DevMapPage: typeof MapInspector;
343
332
 
344
333
  //# sourceMappingURL=index.d.ts.map