@macrostrat/map-interface 1.2.2 → 1.2.3

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 (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/{container.72611900.js → container.b61e4d0f.js} +2 -2
  3. package/dist/cjs/{container.72611900.js.map → container.b61e4d0f.js.map} +1 -1
  4. package/dist/cjs/{dev.10ac2fb3.js → dev.8ee72000.js} +2 -2
  5. package/dist/{esm/dev.30b435dc.js.map → cjs/dev.8ee72000.js.map} +1 -1
  6. package/dist/cjs/index.js +5 -5
  7. package/dist/cjs/{location-panel.42ca3200.js → location-panel.6a4dc310.js} +2 -2
  8. package/dist/cjs/{location-panel.42ca3200.js.map → location-panel.6a4dc310.js.map} +1 -1
  9. package/dist/cjs/{map-page.9c19b2a9.js → map-page.cde24ee5.js} +5 -5
  10. package/dist/cjs/{map-page.9c19b2a9.js.map → map-page.cde24ee5.js.map} +1 -1
  11. package/dist/cjs/map-view.12e9ea3e.js +178 -0
  12. package/dist/cjs/map-view.12e9ea3e.js.map +1 -0
  13. package/dist/esm/{container.16bde261.js → container.2ebe27af.js} +2 -2
  14. package/dist/esm/{container.16bde261.js.map → container.2ebe27af.js.map} +1 -1
  15. package/dist/esm/{dev.30b435dc.js → dev.58b994e7.js} +2 -2
  16. package/dist/{cjs/dev.10ac2fb3.js.map → esm/dev.58b994e7.js.map} +1 -1
  17. package/dist/esm/index.d.ts +2 -1
  18. package/dist/esm/index.d.ts.map +1 -1
  19. package/dist/esm/index.js +5 -5
  20. package/dist/esm/{location-panel.b56899ab.js → location-panel.f22673f5.js} +2 -2
  21. package/dist/esm/{location-panel.b56899ab.js.map → location-panel.f22673f5.js.map} +1 -1
  22. package/dist/esm/{map-page.93c11cef.js → map-page.f9f59ea0.js} +5 -5
  23. package/dist/esm/{map-page.93c11cef.js.map → map-page.f9f59ea0.js.map} +1 -1
  24. package/dist/esm/map-view.4f256782.js +172 -0
  25. package/dist/esm/map-view.4f256782.js.map +1 -0
  26. package/dist/node/container.abd6f0d2.js.map +1 -1
  27. package/dist/node/{dev.ee1e89e9.js → dev.3cbf6106.js} +2 -2
  28. package/dist/node/{dev.ee1e89e9.js.map → dev.3cbf6106.js.map} +1 -1
  29. package/dist/node/index.js +1 -1
  30. package/dist/node/index.js.map +1 -1
  31. package/dist/node/{map-page.cb4c713e.js → map-page.f99c4a48.js} +2 -2
  32. package/dist/node/{map-page.cb4c713e.js.map → map-page.f99c4a48.js.map} +1 -1
  33. package/dist/node/map-view.77013338.js +2 -0
  34. package/dist/node/map-view.77013338.js.map +1 -0
  35. package/package.json +3 -3
  36. package/src/container.ts +1 -1
  37. package/src/{map-view/index.ts → map-view.ts} +51 -18
  38. package/dist/cjs/map-view.93363b41.js +0 -167
  39. package/dist/cjs/map-view.93363b41.js.map +0 -1
  40. package/dist/cjs/terrain.90f76b4e.js +0 -59
  41. package/dist/cjs/terrain.90f76b4e.js.map +0 -1
  42. package/dist/esm/map-view.a3fe6257.js +0 -161
  43. package/dist/esm/map-view.a3fe6257.js.map +0 -1
  44. package/dist/esm/terrain.f65cf7c5.js +0 -54
  45. package/dist/esm/terrain.f65cf7c5.js.map +0 -1
  46. package/dist/node/map-view.c6746dca.js +0 -2
  47. package/dist/node/map-view.c6746dca.js.map +0 -1
  48. package/dist/node/terrain.96ae432a.js +0 -2
  49. package/dist/node/terrain.96ae432a.js.map +0 -1
  50. package/src/map-view/terrain.ts +0 -63
@@ -0,0 +1 @@
1
+ {"mappings":"A,Q,8C,Q,+C,Q,0C,Q,wC,I,E,Q,qB,S,E,C,E,O,G,E,U,C,E,O,C,C,C,Q,4B,Q,4B,Q,c,Q,a,Q,S,Q,gC,Q,6B,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,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,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,S,E,SC8BU,AAAA,AAAA,EAAA,GAAM,MAAM,CAAC,EAAA","sources":["<anon>","packages/map-interface/src/map-view.ts"],"sourcesContent":["require(\"./main.module.24615279.js\");\nrequire(\"./main.module.89f269c7.css\");\nrequire(\"./helpers.6bda171f.js\");\nrequire(\"./utils.dd92f725.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\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire94c2\"];\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[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\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 console.log(\"Initializing map (default)\", args);\n const map = new (0, ($parcel$interopDefault($iE1eH$mapboxgl))).Map({\n container: container,\n maxZoom: 18,\n //maxTileCacheSize: 0,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest\n });\n // set initial map position\n if (mapPosition != null) (0, $iE1eH$macrostratmapboxutils.setMapPosition)(map, mapPosition);\n //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 = $8c5236898eee97dc$var$defaultMapPosition, 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, ...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 (0, $iE1eH$macrostratuicomponents.useAsyncEffect)(async ()=>{\n /** Manager to update map style */ if (style == 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 let newStyle = style;\n const { mapUse3D: mapUse3D } = (0, $iE1eH$macrostratmapboxutils.mapViewInfo)(estMapPosition);\n /** If style is a string, we can't update it with terrain layers immediately.\n * We need to wait for the style to load and then update it.\n */ if (typeof style === \"string\") newStyle = await (0, $iE1eH$macrostratmapboxutils.getMapboxStyle)(style, {\n access_token: (0, ($parcel$interopDefault($iE1eH$mapboxgl))).accessToken\n });\n if (mapUse3D) // We can update the style with terrain layers immediately\n newStyle = (0, $iE1eH$macrostratmapboxreact.addTerrainToStyle)(newStyle, terrainSourceID);\n if (map != null) {\n console.log(\"Setting style\", newStyle);\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 const loadCallback = ()=>{\n onStyleLoaded?.(map);\n // Set initial terrain state\n dispatch({\n type: \"set-style-loaded\",\n payload: true\n });\n };\n map = mapRef.current;\n if (map.style?._loaded) // Catch a race condition where the style is loaded before the callback is set\n loadCallback();\n map.on(\"style.load\", loadCallback);\n return ()=>{\n map.off(\"style.load\", loadCallback);\n };\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 return $8c5236898eee97dc$var$h(\"div.map-view-container.main-view\", {\n ref: parentRef\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-view.77013338.js.map\n","import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n setup3DTerrain,\n use3DTerrain,\n addTerrainToStyle,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef } 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}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n console.log(\"Initializing map (default)\", args);\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n //maxTileCacheSize: 0,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest,\n });\n\n // set initial map position\n if (mapPosition != null) {\n setMapPosition(map, mapPosition);\n }\n\n //setMapPosition(map, mapPosition);\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition = defaultMapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n if (style == 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 let newStyle = style;\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n /** If style is a string, we can't update it with terrain layers immediately.\n * We need to wait for the style to load and then update it.\n */\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n }\n\n if (mapUse3D) {\n // We can update the style with terrain layers immediately\n newStyle = addTerrainToStyle(newStyle as mapboxgl.Style, terrainSourceID);\n }\n\n if (map != null) {\n console.log(\"Setting style\", newStyle);\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\n const loadCallback = () => {\n onStyleLoaded?.(map);\n // Set initial terrain state\n dispatch({ type: \"set-style-loaded\", payload: true });\n };\n\n map = mapRef.current;\n\n if (map.style?._loaded) {\n // Catch a race condition where the style is loaded before the callback is set\n loadCallback();\n }\n map.on(\"style.load\", loadCallback);\n return () => {\n map.off(\"style.load\", loadCallback);\n };\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`\n );\n\n return h(\"div.map-view-container.main-view\", { ref: parentRef }, [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, { containerRef: ref, parentRef, infoMarkerPosition }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\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","$parcel$interopDefault","a","__esModule","default","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$6ULxP","styled"],"version":3,"file":"map-view.77013338.js.map","sourceRoot":"../../../../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/map-interface",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Map interface for Macrostrat",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -11,9 +11,9 @@
11
11
  "@blueprintjs/core": "^5.0.0",
12
12
  "@macrostrat/color-utils": "^1.0.1",
13
13
  "@macrostrat/hyper": "^3.0.6",
14
- "@macrostrat/mapbox-react": "^2.5.0",
14
+ "@macrostrat/mapbox-react": "^2.5.1",
15
15
  "@macrostrat/mapbox-utils": "^1.4.0",
16
- "@macrostrat/ui-components": "^4.1.2",
16
+ "@macrostrat/ui-components": "^4.1.3",
17
17
  "@mapbox/tilebelt": "^2.0.0",
18
18
  "classnames": "^2.5.1",
19
19
  "d3-array": "^3.2.4",
package/src/container.ts CHANGED
@@ -118,7 +118,7 @@ function _MapAreaContainer({
118
118
  );
119
119
 
120
120
  let contextStack = null;
121
- if (navbar != null && contextPanel != null) {
121
+ if (navbar != null || contextPanel != null) {
122
122
  contextStack = h(ContextStack, { navbar, ...contextStackProps }, [
123
123
  h.if(contextPanelTrans.shouldMount)([contextPanel]),
124
124
  ]);
@@ -3,25 +3,30 @@ import {
3
3
  useMapRef,
4
4
  useMapDispatch,
5
5
  useMapPosition,
6
+ setup3DTerrain,
7
+ use3DTerrain,
8
+ addTerrainToStyle,
6
9
  } from "@macrostrat/mapbox-react";
7
10
  import {
8
11
  mapViewInfo,
9
12
  MapPosition,
10
13
  setMapPosition,
14
+ getMapPosition,
15
+ getMapboxStyle,
11
16
  } from "@macrostrat/mapbox-utils";
12
17
  import classNames from "classnames";
13
18
  import mapboxgl from "mapbox-gl";
14
- import { useEffect, useRef, useCallback } from "react";
15
- import styles from "../main.module.sass";
16
- import { enable3DTerrain } from "./terrain";
19
+ import { useEffect, useRef } from "react";
20
+ import styles from "./main.module.sass";
17
21
  import {
18
22
  MapLoadingReporter,
19
23
  MapMovedReporter,
20
24
  MapPaddingManager,
21
25
  MapResizeManager,
22
- } from "../helpers";
26
+ } from "./helpers";
23
27
  import "mapbox-gl/dist/mapbox-gl.css";
24
- import { getMapPadding } from "../utils";
28
+ import { getMapPadding } from "./utils";
29
+ import { useAsyncEffect } from "@macrostrat/ui-components";
25
30
 
26
31
  const h = hyper.styled(styles);
27
32
 
@@ -116,16 +121,45 @@ export function MapView(props: MapViewProps) {
116
121
  const ref = useRef<HTMLDivElement>();
117
122
  const parentRef = useRef<HTMLDivElement>();
118
123
 
119
- useEffect(() => {
124
+ useAsyncEffect(async () => {
125
+ /** Manager to update map style */
120
126
  if (style == null) return;
121
127
  let map = mapRef.current;
128
+
129
+ /** If we can, we try to update the map style with terrain information
130
+ * immediately, before the style is loaded. This allows us to avoid a
131
+ * flash of the map without terrain.
132
+ *
133
+ * To do this, we need to estimate the map position before load, which
134
+ * doesn't always work.
135
+ */
136
+ // We either get the map position directly from the map or from props
137
+ const estMapPosition: MapPosition | null =
138
+ map == null ? mapPosition : getMapPosition(map);
139
+ let newStyle = style;
140
+ const { mapUse3D } = mapViewInfo(estMapPosition);
141
+
142
+ /** If style is a string, we can't update it with terrain layers immediately.
143
+ * We need to wait for the style to load and then update it.
144
+ */
145
+ if (typeof style === "string") {
146
+ newStyle = await getMapboxStyle(style, {
147
+ access_token: mapboxgl.accessToken,
148
+ });
149
+ }
150
+
151
+ if (mapUse3D) {
152
+ // We can update the style with terrain layers immediately
153
+ newStyle = addTerrainToStyle(newStyle as mapboxgl.Style, terrainSourceID);
154
+ }
155
+
122
156
  if (map != null) {
123
- console.log("Setting style", style);
124
- map.setStyle(style);
157
+ console.log("Setting style", newStyle);
158
+ map.setStyle(newStyle);
125
159
  } else {
126
- console.log("Initializing map", style);
160
+ console.log("Initializing map", newStyle);
127
161
  const map = initializeMap(ref.current, {
128
- style,
162
+ style: newStyle,
129
163
  projection,
130
164
  mapPosition,
131
165
  transformRequest,
@@ -138,11 +172,13 @@ export function MapView(props: MapViewProps) {
138
172
 
139
173
  const loadCallback = () => {
140
174
  onStyleLoaded?.(map);
175
+ // Set initial terrain state
141
176
  dispatch({ type: "set-style-loaded", payload: true });
142
177
  };
143
178
 
144
179
  map = mapRef.current;
145
- if (map.isStyleLoaded()) {
180
+
181
+ if (map.style?._loaded) {
146
182
  // Catch a race condition where the style is loaded before the callback is set
147
183
  loadCallback();
148
184
  }
@@ -174,7 +210,7 @@ export function MapView(props: MapViewProps) {
174
210
  h(MapMovedReporter, { onMapMoved }),
175
211
  h(MapResizeManager, { containerRef: ref }),
176
212
  h(MapPaddingManager, { containerRef: ref, parentRef, infoMarkerPosition }),
177
- h(MapTerrainManager, { mapUse3D, terrainSourceID }),
213
+ h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),
178
214
  children,
179
215
  ]);
180
216
  }
@@ -182,16 +218,13 @@ export function MapView(props: MapViewProps) {
182
218
  export function MapTerrainManager({
183
219
  mapUse3D,
184
220
  terrainSourceID,
221
+ style,
185
222
  }: {
186
223
  mapUse3D?: boolean;
187
224
  terrainSourceID?: string;
225
+ style?: mapboxgl.Style | string;
188
226
  }) {
189
- const mapRef = useMapRef();
227
+ use3DTerrain(mapUse3D, terrainSourceID);
190
228
 
191
- useEffect(() => {
192
- const map = mapRef.current;
193
- if (map == null) return;
194
- enable3DTerrain(map, mapUse3D, terrainSourceID);
195
- }, [mapRef.current, mapUse3D]);
196
229
  return null;
197
230
  }
@@ -1,167 +0,0 @@
1
- var $35f1bc0112883d51$exports = require("./main.module.62939ea7.js");
2
- require("./main.module.f085a193.css");
3
- var $ecfbeec2ae4211a4$exports = require("./terrain.90f76b4e.js");
4
- var $2611a7b4364593e5$exports = require("./helpers.0f72ddaf.js");
5
- var $3490fc4f4bda12f7$exports = require("./utils.26f02633.js");
6
- var $3Vvow$macrostrathyper = require("@macrostrat/hyper");
7
- var $3Vvow$macrostratmapboxreact = require("@macrostrat/mapbox-react");
8
- var $3Vvow$macrostratmapboxutils = require("@macrostrat/mapbox-utils");
9
- var $3Vvow$classnames = require("classnames");
10
- var $3Vvow$mapboxgl = require("mapbox-gl");
11
- var $3Vvow$react = require("react");
12
- require("mapbox-gl/dist/mapbox-gl.css");
13
-
14
-
15
- function $parcel$interopDefault(a) {
16
- return a && a.__esModule ? a.default : a;
17
- }
18
-
19
- function $parcel$export(e, n, v, s) {
20
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
21
- }
22
-
23
- $parcel$export(module.exports, "MapView", () => $12b6032029db16d4$export$ab1e7a67d6ec5ad8);
24
- $parcel$export(module.exports, "MapTerrainManager", () => $12b6032029db16d4$export$cee395a8a2a00b29);
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
- const $12b6032029db16d4$var$h = (0, ($parcel$interopDefault($3Vvow$macrostrathyper))).styled((0, ($parcel$interopDefault($35f1bc0112883d51$exports))));
37
- function $12b6032029db16d4$var$defaultInitializeMap(container, args = {}) {
38
- const { mapPosition: mapPosition, ...rest } = args;
39
- console.log("Initializing map (default)", args);
40
- const map = new (0, ($parcel$interopDefault($3Vvow$mapboxgl))).Map({
41
- container: container,
42
- maxZoom: 18,
43
- //maxTileCacheSize: 0,
44
- logoPosition: "bottom-left",
45
- trackResize: true,
46
- antialias: true,
47
- optimizeForTerrain: true,
48
- ...rest
49
- });
50
- // set initial map position
51
- if (mapPosition != null) (0, $3Vvow$macrostratmapboxutils.setMapPosition)(map, mapPosition);
52
- //setMapPosition(map, mapPosition);
53
- return map;
54
- }
55
- const $12b6032029db16d4$var$defaultMapPosition = {
56
- camera: {
57
- lat: 34,
58
- lng: -120,
59
- altitude: 300000
60
- }
61
- };
62
- function $12b6032029db16d4$export$ab1e7a67d6ec5ad8(props) {
63
- let { terrainSourceID: terrainSourceID } = props;
64
- const { enableTerrain: enableTerrain = true, style: style, mapPosition: mapPosition = $12b6032029db16d4$var$defaultMapPosition, initializeMap: initializeMap = $12b6032029db16d4$var$defaultInitializeMap, children: children, mapboxToken: mapboxToken, accessToken: // Deprecated
65
- accessToken, infoMarkerPosition: infoMarkerPosition, transformRequest: transformRequest, projection: projection, onMapLoaded: onMapLoaded = null, onStyleLoaded: onStyleLoaded = null, onMapMoved: onMapMoved = null, ...rest } = props;
66
- if (enableTerrain) terrainSourceID ??= "mapbox-3d-dem";
67
- const _mapboxToken = mapboxToken ?? accessToken;
68
- if (_mapboxToken != null) (0, ($parcel$interopDefault($3Vvow$mapboxgl))).accessToken = _mapboxToken;
69
- const dispatch = (0, $3Vvow$macrostratmapboxreact.useMapDispatch)();
70
- let mapRef = (0, $3Vvow$macrostratmapboxreact.useMapRef)();
71
- const ref = (0, $3Vvow$react.useRef)();
72
- const parentRef = (0, $3Vvow$react.useRef)();
73
- (0, $3Vvow$react.useEffect)(()=>{
74
- if (style == null) return;
75
- let map = mapRef.current;
76
- if (map != null) {
77
- console.log("Setting style", style);
78
- map.setStyle(style);
79
- } else {
80
- console.log("Initializing map", style);
81
- const map = initializeMap(ref.current, {
82
- style: style,
83
- projection: projection,
84
- mapPosition: mapPosition,
85
- transformRequest: transformRequest,
86
- ...rest
87
- });
88
- dispatch({
89
- type: "set-map",
90
- payload: map
91
- });
92
- map.setPadding((0, $3490fc4f4bda12f7$exports.getMapPadding)(ref, parentRef), {
93
- animate: false
94
- });
95
- onMapLoaded?.(map);
96
- }
97
- const loadCallback = ()=>{
98
- onStyleLoaded?.(map);
99
- dispatch({
100
- type: "set-style-loaded",
101
- payload: true
102
- });
103
- };
104
- map = mapRef.current;
105
- if (map.isStyleLoaded()) // Catch a race condition where the style is loaded before the callback is set
106
- loadCallback();
107
- map.on("style.load", loadCallback);
108
- return ()=>{
109
- map.off("style.load", loadCallback);
110
- };
111
- }, [
112
- style
113
- ]);
114
- const _computedMapPosition = (0, $3Vvow$macrostratmapboxreact.useMapPosition)();
115
- const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $3Vvow$macrostratmapboxutils.mapViewInfo)(_computedMapPosition);
116
- // Get map projection
117
- const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
118
- const className = (0, ($parcel$interopDefault($3Vvow$classnames)))({
119
- "is-rotated": mapIsRotated ?? false,
120
- "is-3d-available": mapUse3D ?? false
121
- }, `${_projection}-projection`);
122
- return $12b6032029db16d4$var$h("div.map-view-container.main-view", {
123
- ref: parentRef
124
- }, [
125
- $12b6032029db16d4$var$h("div.mapbox-map#map", {
126
- ref: ref,
127
- className: className
128
- }),
129
- $12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapLoadingReporter), {
130
- ignoredSources: [
131
- "elevationMarker",
132
- "crossSectionEndpoints"
133
- ]
134
- }),
135
- $12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapMovedReporter), {
136
- onMapMoved: onMapMoved
137
- }),
138
- $12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapResizeManager), {
139
- containerRef: ref
140
- }),
141
- $12b6032029db16d4$var$h((0, $2611a7b4364593e5$exports.MapPaddingManager), {
142
- containerRef: ref,
143
- parentRef: parentRef,
144
- infoMarkerPosition: infoMarkerPosition
145
- }),
146
- $12b6032029db16d4$var$h($12b6032029db16d4$export$cee395a8a2a00b29, {
147
- mapUse3D: mapUse3D,
148
- terrainSourceID: terrainSourceID
149
- }),
150
- children
151
- ]);
152
- }
153
- function $12b6032029db16d4$export$cee395a8a2a00b29({ mapUse3D: mapUse3D, terrainSourceID: terrainSourceID }) {
154
- const mapRef = (0, $3Vvow$macrostratmapboxreact.useMapRef)();
155
- (0, $3Vvow$react.useEffect)(()=>{
156
- const map = mapRef.current;
157
- if (map == null) return;
158
- (0, $ecfbeec2ae4211a4$exports.enable3DTerrain)(map, mapUse3D, terrainSourceID);
159
- }, [
160
- mapRef.current,
161
- mapUse3D
162
- ]);
163
- return null;
164
- }
165
-
166
-
167
- //# sourceMappingURL=map-view.93363b41.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AA2B5B,SAAS,2CAAqB,SAAS,EAAE,OAAyB,CAAC,CAAC;IAClE,MAAM,eAAE,WAAW,EAAE,GAAG,MAAM,GAAG;IACjC,QAAQ,GAAG,CAAC,8BAA8B;IAE1C,MAAM,MAAM,IAAI,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;mBAC3B;QACA,SAAS;QACT,sBAAsB;QACtB,cAAc;QACd,aAAa;QACb,WAAW;QACX,oBAAoB;QACpB,GAAG,IAAI;IACT;IAEA,2BAA2B;IAC3B,IAAI,eAAe,MACjB,CAAA,GAAA,2CAAa,EAAE,KAAK;IAGtB,mCAAmC;IACnC,OAAO;AACT;AAEA,MAAM,2CAAkC;IACtC,QAAQ;QACN,KAAK;QACL,KAAK;QACL,UAAU;IACZ;AACF;AAEO,SAAS,0CAAQ,KAAmB;IACzC,IAAI,mBAAE,eAAe,EAAE,GAAG;IAC1B,MAAM,iBACJ,gBAAgB,aAChB,KAAK,eACL,cAAc,yDACd,gBAAgB,sDAChB,QAAQ,eACR,WAAW,eACX,aAAa;IACb,WAAW,sBACX,kBAAkB,oBAClB,gBAAgB,cAChB,UAAU,eACV,cAAc,qBACd,gBAAgB,kBAChB,aAAa,MACb,GAAG,MACJ,GAAG;IACJ,IAAI,eACF,oBAAoB;IAGtB,MAAM,eAAe,eAAe;IAEpC,IAAI,gBAAgB,MAClB,CAAA,GAAA,yCAAO,EAAE,WAAW,GAAG;IAGzB,MAAM,WAAW,CAAA,GAAA,2CAAa;IAC9B,IAAI,SAAS,CAAA,GAAA,sCAAQ;IACrB,MAAM,MAAM,CAAA,GAAA,mBAAK;IACjB,MAAM,YAAY,CAAA,GAAA,mBAAK;IAEvB,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,SAAS,MAAM;QACnB,IAAI,MAAM,OAAO,OAAO;QACxB,IAAI,OAAO,MAAM;YACf,QAAQ,GAAG,CAAC,iBAAiB;YAC7B,IAAI,QAAQ,CAAC;QACf,OAAO;YACL,QAAQ,GAAG,CAAC,oBAAoB;YAChC,MAAM,MAAM,cAAc,IAAI,OAAO,EAAE;uBACrC;4BACA;6BACA;kCACA;gBACA,GAAG,IAAI;YACT;YACA,SAAS;gBAAE,MAAM;gBAAW,SAAS;YAAI;YACzC,IAAI,UAAU,CAAC,CAAA,GAAA,uCAAY,EAAE,KAAK,YAAY;gBAAE,SAAS;YAAM;YAC/D,cAAc;QAChB;QAEA,MAAM,eAAe;YACnB,gBAAgB;YAChB,SAAS;gBAAE,MAAM;gBAAoB,SAAS;YAAK;QACrD;QAEA,MAAM,OAAO,OAAO;QACpB,IAAI,IAAI,aAAa,IACnB,8EAA8E;QAC9E;QAEF,IAAI,EAAE,CAAC,cAAc;QACrB,OAAO;YACL,IAAI,GAAG,CAAC,cAAc;QACxB;IACF,GAAG;QAAC;KAAM;IAEV,MAAM,uBAAuB,CAAA,GAAA,2CAAa;IAC1C,MAAM,YAAE,QAAQ,gBAAE,YAAY,EAAE,GAAG,CAAA,GAAA,wCAAU,EAAE;IAE/C,qBAAqB;IACrB,MAAM,cAAc,OAAO,OAAO,EAAE,iBAAiB,QAAQ;IAE7D,MAAM,YAAY,CAAA,GAAA,2CAAS,EACzB;QACE,cAAc,gBAAgB;QAC9B,mBAAmB,YAAY;IACjC,GACA,GAAG,YAAY,WAAW,CAAC;IAG7B,OAAO,wBAAE,oCAAoC;QAAE,KAAK;IAAU,GAAG;QAC/D,wBAAE,sBAAsB;iBAAE;uBAAK;QAAU;QACzC,wBAAE,CAAA,GAAA,4CAAiB,GAAG;YACpB,gBAAgB;gBAAC;gBAAmB;aAAwB;QAC9D;QACA,wBAAE,CAAA,GAAA,0CAAe,GAAG;wBAAE;QAAW;QACjC,wBAAE,CAAA,GAAA,0CAAe,GAAG;YAAE,cAAc;QAAI;QACxC,wBAAE,CAAA,GAAA,2CAAgB,GAAG;YAAE,cAAc;uBAAK;gCAAW;QAAmB;QACxE,wBAAE,2CAAmB;sBAAE;6BAAU;QAAgB;QACjD;KACD;AACH;AAEO,SAAS,0CAAkB,YAChC,QAAQ,mBACR,eAAe,EAIhB;IACC,MAAM,SAAS,CAAA,GAAA,sCAAQ;IAEvB,CAAA,GAAA,sBAAQ,EAAE;QACR,MAAM,MAAM,OAAO,OAAO;QAC1B,IAAI,OAAO,MAAM;QACjB,CAAA,GAAA,yCAAc,EAAE,KAAK,UAAU;IACjC,GAAG;QAAC,OAAO,OAAO;QAAE;KAAS;IAC7B,OAAO;AACT","sources":["packages/map-interface/src/map-view/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useCallback } from \"react\";\nimport styles from \"../main.module.sass\";\nimport { enable3DTerrain } from \"./terrain\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"../helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"../utils\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n console.log(\"Initializing map (default)\", args);\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n //maxTileCacheSize: 0,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest,\n });\n\n // set initial map position\n if (mapPosition != null) {\n setMapPosition(map, mapPosition);\n }\n\n //setMapPosition(map, mapPosition);\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition = defaultMapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n useEffect(() => {\n if (style == null) return;\n let map = mapRef.current;\n if (map != null) {\n console.log(\"Setting style\", style);\n map.setStyle(style);\n } else {\n console.log(\"Initializing map\", style);\n const map = initializeMap(ref.current, {\n style,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n\n const loadCallback = () => {\n onStyleLoaded?.(map);\n dispatch({ type: \"set-style-loaded\", payload: true });\n };\n\n map = mapRef.current;\n if (map.isStyleLoaded()) {\n // Catch a race condition where the style is loaded before the callback is set\n loadCallback();\n }\n map.on(\"style.load\", loadCallback);\n return () => {\n map.off(\"style.load\", loadCallback);\n };\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`\n );\n\n return h(\"div.map-view-container.main-view\", { ref: parentRef }, [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, { containerRef: ref, parentRef, infoMarkerPosition }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID }),\n children,\n ]);\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n}) {\n const mapRef = useMapRef();\n\n useEffect(() => {\n const map = mapRef.current;\n if (map == null) return;\n enable3DTerrain(map, mapUse3D, terrainSourceID);\n }, [mapRef.current, mapUse3D]);\n return null;\n}\n"],"names":[],"version":3,"file":"map-view.93363b41.js.map"}
@@ -1,59 +0,0 @@
1
-
2
- function $parcel$export(e, n, v, s) {
3
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
- }
5
-
6
- $parcel$export(module.exports, "enable3DTerrain", () => $ecfbeec2ae4211a4$export$b730542ee281c4b1);
7
- // We should merge this with code in @macrostrat/mapbox-react/src/terrain.ts:
8
- function $ecfbeec2ae4211a4$export$b730542ee281c4b1(map, shouldEnable, sourceID = null) {
9
- if (!map.style?._loaded) {
10
- map.once("style.load", ()=>{
11
- $ecfbeec2ae4211a4$export$b730542ee281c4b1(map, shouldEnable, sourceID);
12
- });
13
- return;
14
- }
15
- const currentTerrainSource = $ecfbeec2ae4211a4$var$getTerrainSourceID(map);
16
- let demSourceID = sourceID ?? currentTerrainSource ?? "mapbox-dem";
17
- console.log("Enabling 3D terrain with source", demSourceID);
18
- // Enable or disable terrain depending on our current desires...
19
- const currentTerrain = map.getTerrain();
20
- if (!shouldEnable) {
21
- if (currentTerrain != null) map.setTerrain(null);
22
- return;
23
- }
24
- if (currentTerrain != null) return;
25
- // Add a DEM source if one is not found already.
26
- if (map.getSource(demSourceID) == null) map.addSource(demSourceID, {
27
- type: "raster-dem",
28
- url: "mapbox://mapbox.mapbox-terrain-dem-v1",
29
- tileSize: 512,
30
- maxzoom: 14
31
- });
32
- // add a sky layer that will show when the map is highly pitched
33
- if (map.getLayer("sky") == null) map.addLayer({
34
- id: "sky",
35
- type: "sky",
36
- paint: {
37
- "sky-type": "atmosphere",
38
- "sky-atmosphere-sun": [
39
- 0.0,
40
- 0.0
41
- ],
42
- "sky-atmosphere-sun-intensity": 15
43
- }
44
- });
45
- map.setTerrain({
46
- source: demSourceID,
47
- exaggeration: 1
48
- });
49
- console.log(map.getTerrain());
50
- }
51
- function $ecfbeec2ae4211a4$var$getTerrainSourceID(map) {
52
- for (const [key, source] of Object.entries(map.getStyle().sources)){
53
- if (source.type == "raster-dem") return key;
54
- }
55
- return null;
56
- }
57
-
58
-
59
- //# sourceMappingURL=terrain.90f76b4e.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAAA,6EAA6E;AAEtE,SAAS,0CACd,GAAG,EACH,YAAqB,EACrB,WAA0B,IAAI;IAE9B,IAAI,CAAC,IAAI,KAAK,EAAE,SAAS;QACvB,IAAI,IAAI,CAAC,cAAc;YACrB,0CAAgB,KAAK,cAAc;QACrC;QACA;IACF;IAEA,MAAM,uBAAuB,yCAAmB;IAChD,IAAI,cAAc,YAAY,wBAAwB;IAEtD,QAAQ,GAAG,CAAC,mCAAmC;IAE/C,gEAAgE;IAChE,MAAM,iBAAiB,IAAI,UAAU;IAErC,IAAI,CAAC,cAAc;QACjB,IAAI,kBAAkB,MAAM,IAAI,UAAU,CAAC;QAC3C;IACF;IACA,IAAI,kBAAkB,MAAM;IAE5B,gDAAgD;IAChD,IAAI,IAAI,SAAS,CAAC,gBAAgB,MAChC,IAAI,SAAS,CAAC,aAAa;QACzB,MAAM;QACN,KAAK;QACL,UAAU;QACV,SAAS;IACX;IAGF,gEAAgE;IAChE,IAAI,IAAI,QAAQ,CAAC,UAAU,MACzB,IAAI,QAAQ,CAAC;QACX,IAAI;QACJ,MAAM;QACN,OAAO;YACL,YAAY;YACZ,sBAAsB;gBAAC;gBAAK;aAAI;YAChC,gCAAgC;QAClC;IACF;IAGF,IAAI,UAAU,CAAC;QAAE,QAAQ;QAAa,cAAc;IAAE;IACtD,QAAQ,GAAG,CAAC,IAAI,UAAU;AAC5B;AAEA,SAAS,yCAAmB,GAAG;IAC7B,KAAK,MAAM,CAAC,KAAK,OAAO,IAAI,OAAO,OAAO,CAAC,IAAI,QAAQ,GAAG,OAAO,EAAG;QAClE,IAAI,OAAO,IAAI,IAAI,cACjB,OAAO;IAEX;IACA,OAAO;AACT","sources":["packages/map-interface/src/map-view/terrain.ts"],"sourcesContent":["// We should merge this with code in @macrostrat/mapbox-react/src/terrain.ts:\n\nexport function enable3DTerrain(\n map,\n shouldEnable: boolean,\n sourceID: string | null = null\n) {\n if (!map.style?._loaded) {\n map.once(\"style.load\", () => {\n enable3DTerrain(map, shouldEnable, sourceID);\n });\n return;\n }\n\n const currentTerrainSource = getTerrainSourceID(map);\n let demSourceID = sourceID ?? currentTerrainSource ?? \"mapbox-dem\";\n\n console.log(\"Enabling 3D terrain with source\", demSourceID);\n\n // Enable or disable terrain depending on our current desires...\n const currentTerrain = map.getTerrain();\n\n if (!shouldEnable) {\n if (currentTerrain != null) map.setTerrain(null);\n return;\n }\n if (currentTerrain != null) return;\n\n // Add a DEM source if one is not found already.\n if (map.getSource(demSourceID) == null) {\n map.addSource(demSourceID, {\n type: \"raster-dem\",\n url: \"mapbox://mapbox.mapbox-terrain-dem-v1\",\n tileSize: 512,\n maxzoom: 14,\n });\n }\n\n // add a sky layer that will show when the map is highly pitched\n if (map.getLayer(\"sky\") == null) {\n map.addLayer({\n id: \"sky\",\n type: \"sky\",\n paint: {\n \"sky-type\": \"atmosphere\",\n \"sky-atmosphere-sun\": [0.0, 0.0],\n \"sky-atmosphere-sun-intensity\": 15,\n },\n });\n }\n\n map.setTerrain({ source: demSourceID, exaggeration: 1 });\n console.log(map.getTerrain());\n}\n\nfunction getTerrainSourceID(map) {\n for (const [key, source] of Object.entries(map.getStyle().sources)) {\n if (source.type == \"raster-dem\") {\n return key;\n }\n }\n return null;\n}\n"],"names":[],"version":3,"file":"terrain.90f76b4e.js.map"}
@@ -1,161 +0,0 @@
1
- import $44I7C$mainmodulef70e002bjs from "./main.module.f70e002b.js";
2
- import "../cjs/main.module.f085a193.css";
3
- import {enable3DTerrain as $286fbb15f2139dc1$export$b730542ee281c4b1} from "./terrain.f65cf7c5.js";
4
- import {MapLoadingReporter as $4bc3dd5f0732eed3$export$e57f9eaa51773f82, MapMovedReporter as $4bc3dd5f0732eed3$export$f6eeee399afc4e9a, MapResizeManager as $4bc3dd5f0732eed3$export$31b2e088aff2dc5d, MapPaddingManager as $4bc3dd5f0732eed3$export$2ab96428dea558d6} from "./helpers.fb1d7227.js";
5
- import {getMapPadding as $82fe09613877ffc2$export$bb78f9f01775eef1} from "./utils.d40349f0.js";
6
- import $44I7C$macrostrathyper from "@macrostrat/hyper";
7
- import {useMapDispatch as $44I7C$useMapDispatch, useMapRef as $44I7C$useMapRef, useMapPosition as $44I7C$useMapPosition} from "@macrostrat/mapbox-react";
8
- import {setMapPosition as $44I7C$setMapPosition, mapViewInfo as $44I7C$mapViewInfo} from "@macrostrat/mapbox-utils";
9
- import $44I7C$classnames from "classnames";
10
- import $44I7C$mapboxgl from "mapbox-gl";
11
- import {useRef as $44I7C$useRef, useEffect as $44I7C$useEffect} from "react";
12
- import "mapbox-gl/dist/mapbox-gl.css";
13
-
14
-
15
- function $parcel$interopDefault(a) {
16
- return a && a.__esModule ? a.default : a;
17
- }
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
- const $9e150e311a3261e9$var$h = (0, $44I7C$macrostrathyper).styled((0, ($parcel$interopDefault($44I7C$mainmodulef70e002bjs))));
30
- function $9e150e311a3261e9$var$defaultInitializeMap(container, args = {}) {
31
- const { mapPosition: mapPosition, ...rest } = args;
32
- console.log("Initializing map (default)", args);
33
- const map = new (0, $44I7C$mapboxgl).Map({
34
- container: container,
35
- maxZoom: 18,
36
- //maxTileCacheSize: 0,
37
- logoPosition: "bottom-left",
38
- trackResize: true,
39
- antialias: true,
40
- optimizeForTerrain: true,
41
- ...rest
42
- });
43
- // set initial map position
44
- if (mapPosition != null) (0, $44I7C$setMapPosition)(map, mapPosition);
45
- //setMapPosition(map, mapPosition);
46
- return map;
47
- }
48
- const $9e150e311a3261e9$var$defaultMapPosition = {
49
- camera: {
50
- lat: 34,
51
- lng: -120,
52
- altitude: 300000
53
- }
54
- };
55
- function $9e150e311a3261e9$export$ab1e7a67d6ec5ad8(props) {
56
- let { terrainSourceID: terrainSourceID } = props;
57
- const { enableTerrain: enableTerrain = true, style: style, mapPosition: mapPosition = $9e150e311a3261e9$var$defaultMapPosition, initializeMap: initializeMap = $9e150e311a3261e9$var$defaultInitializeMap, children: children, mapboxToken: mapboxToken, accessToken: // Deprecated
58
- accessToken, infoMarkerPosition: infoMarkerPosition, transformRequest: transformRequest, projection: projection, onMapLoaded: onMapLoaded = null, onStyleLoaded: onStyleLoaded = null, onMapMoved: onMapMoved = null, ...rest } = props;
59
- if (enableTerrain) terrainSourceID ??= "mapbox-3d-dem";
60
- const _mapboxToken = mapboxToken ?? accessToken;
61
- if (_mapboxToken != null) (0, $44I7C$mapboxgl).accessToken = _mapboxToken;
62
- const dispatch = (0, $44I7C$useMapDispatch)();
63
- let mapRef = (0, $44I7C$useMapRef)();
64
- const ref = (0, $44I7C$useRef)();
65
- const parentRef = (0, $44I7C$useRef)();
66
- (0, $44I7C$useEffect)(()=>{
67
- if (style == null) return;
68
- let map = mapRef.current;
69
- if (map != null) {
70
- console.log("Setting style", style);
71
- map.setStyle(style);
72
- } else {
73
- console.log("Initializing map", style);
74
- const map = initializeMap(ref.current, {
75
- style: style,
76
- projection: projection,
77
- mapPosition: mapPosition,
78
- transformRequest: transformRequest,
79
- ...rest
80
- });
81
- dispatch({
82
- type: "set-map",
83
- payload: map
84
- });
85
- map.setPadding((0, $82fe09613877ffc2$export$bb78f9f01775eef1)(ref, parentRef), {
86
- animate: false
87
- });
88
- onMapLoaded?.(map);
89
- }
90
- const loadCallback = ()=>{
91
- onStyleLoaded?.(map);
92
- dispatch({
93
- type: "set-style-loaded",
94
- payload: true
95
- });
96
- };
97
- map = mapRef.current;
98
- if (map.isStyleLoaded()) // Catch a race condition where the style is loaded before the callback is set
99
- loadCallback();
100
- map.on("style.load", loadCallback);
101
- return ()=>{
102
- map.off("style.load", loadCallback);
103
- };
104
- }, [
105
- style
106
- ]);
107
- const _computedMapPosition = (0, $44I7C$useMapPosition)();
108
- const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $44I7C$mapViewInfo)(_computedMapPosition);
109
- // Get map projection
110
- const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
111
- const className = (0, $44I7C$classnames)({
112
- "is-rotated": mapIsRotated ?? false,
113
- "is-3d-available": mapUse3D ?? false
114
- }, `${_projection}-projection`);
115
- return $9e150e311a3261e9$var$h("div.map-view-container.main-view", {
116
- ref: parentRef
117
- }, [
118
- $9e150e311a3261e9$var$h("div.mapbox-map#map", {
119
- ref: ref,
120
- className: className
121
- }),
122
- $9e150e311a3261e9$var$h((0, $4bc3dd5f0732eed3$export$e57f9eaa51773f82), {
123
- ignoredSources: [
124
- "elevationMarker",
125
- "crossSectionEndpoints"
126
- ]
127
- }),
128
- $9e150e311a3261e9$var$h((0, $4bc3dd5f0732eed3$export$f6eeee399afc4e9a), {
129
- onMapMoved: onMapMoved
130
- }),
131
- $9e150e311a3261e9$var$h((0, $4bc3dd5f0732eed3$export$31b2e088aff2dc5d), {
132
- containerRef: ref
133
- }),
134
- $9e150e311a3261e9$var$h((0, $4bc3dd5f0732eed3$export$2ab96428dea558d6), {
135
- containerRef: ref,
136
- parentRef: parentRef,
137
- infoMarkerPosition: infoMarkerPosition
138
- }),
139
- $9e150e311a3261e9$var$h($9e150e311a3261e9$export$cee395a8a2a00b29, {
140
- mapUse3D: mapUse3D,
141
- terrainSourceID: terrainSourceID
142
- }),
143
- children
144
- ]);
145
- }
146
- function $9e150e311a3261e9$export$cee395a8a2a00b29({ mapUse3D: mapUse3D, terrainSourceID: terrainSourceID }) {
147
- const mapRef = (0, $44I7C$useMapRef)();
148
- (0, $44I7C$useEffect)(()=>{
149
- const map = mapRef.current;
150
- if (map == null) return;
151
- (0, $286fbb15f2139dc1$export$b730542ee281c4b1)(map, mapUse3D, terrainSourceID);
152
- }, [
153
- mapRef.current,
154
- mapUse3D
155
- ]);
156
- return null;
157
- }
158
-
159
-
160
- export {$9e150e311a3261e9$export$ab1e7a67d6ec5ad8 as MapView, $9e150e311a3261e9$export$cee395a8a2a00b29 as MapTerrainManager};
161
- //# sourceMappingURL=map-view.a3fe6257.js.map
@@ -1 +0,0 @@
1
- {"mappings":"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","sources":["packages/map-interface/src/map-view/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useCallback } from \"react\";\nimport styles from \"../main.module.sass\";\nimport { enable3DTerrain } from \"./terrain\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"../helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"../utils\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n console.log(\"Initializing map (default)\", args);\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n //maxTileCacheSize: 0,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest,\n });\n\n // set initial map position\n if (mapPosition != null) {\n setMapPosition(map, mapPosition);\n }\n\n //setMapPosition(map, mapPosition);\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition = defaultMapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n useEffect(() => {\n if (style == null) return;\n let map = mapRef.current;\n if (map != null) {\n console.log(\"Setting style\", style);\n map.setStyle(style);\n } else {\n console.log(\"Initializing map\", style);\n const map = initializeMap(ref.current, {\n style,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n\n const loadCallback = () => {\n onStyleLoaded?.(map);\n dispatch({ type: \"set-style-loaded\", payload: true });\n };\n\n map = mapRef.current;\n if (map.isStyleLoaded()) {\n // Catch a race condition where the style is loaded before the callback is set\n loadCallback();\n }\n map.on(\"style.load\", loadCallback);\n return () => {\n map.off(\"style.load\", loadCallback);\n };\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`\n );\n\n return h(\"div.map-view-container.main-view\", { ref: parentRef }, [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, { containerRef: ref, parentRef, infoMarkerPosition }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID }),\n children,\n ]);\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n}) {\n const mapRef = useMapRef();\n\n useEffect(() => {\n const map = mapRef.current;\n if (map == null) return;\n enable3DTerrain(map, mapUse3D, terrainSourceID);\n }, [mapRef.current, mapUse3D]);\n return null;\n}\n"],"names":[],"version":3,"file":"map-view.a3fe6257.js.map"}