@macrostrat/map-interface 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/{container.d2e83c46.js → container.fc5b1a23.js} +4 -4
- package/dist/cjs/{container.d2e83c46.js.map → container.fc5b1a23.js.map} +1 -1
- package/dist/cjs/{controls.5fcf8a91.js → controls.9d7ddc44.js} +3 -3
- package/dist/cjs/{controls.5fcf8a91.js.map → controls.9d7ddc44.js.map} +1 -1
- package/dist/cjs/{dev.e6613cda.js → dev.079a11ee.js} +2 -2
- package/dist/cjs/{dev.e6613cda.js.map → dev.079a11ee.js.map} +1 -1
- package/dist/cjs/{header.af864bde.js → header.356d9f4c.js} +2 -2
- package/dist/cjs/header.356d9f4c.js.map +1 -0
- package/dist/cjs/{helpers.0f72ddaf.js → helpers.5a745a3a.js} +21 -3
- package/dist/cjs/helpers.5a745a3a.js.map +1 -0
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/{location-info.92e70042.js → location-info.99003993.js} +13 -3
- package/dist/cjs/location-info.99003993.js.map +1 -0
- package/dist/cjs/{location-panel.e33becf0.js → location-panel.c5a55484.js} +3 -3
- package/dist/cjs/{location-panel.e33becf0.js.map → location-panel.c5a55484.js.map} +1 -1
- package/dist/cjs/main.module.0bbfa859.js.map +1 -1
- package/dist/cjs/{main.module.f57e27f2.css → main.module.16d04f5b.css} +16 -5
- package/dist/cjs/main.module.16d04f5b.css.map +1 -0
- package/dist/cjs/{main.module.62939ea7.js → main.module.e392b038.js} +4 -1
- package/dist/cjs/main.module.e392b038.js.map +1 -0
- package/dist/cjs/main.module.e958948e.js.map +1 -1
- package/dist/cjs/{map-page.1e1970d8.js → map-page.3c65558b.js} +8 -7
- package/dist/cjs/map-page.3c65558b.js.map +1 -0
- package/dist/cjs/{map-view.61e50e18.js → map-view.e031052e.js} +64 -36
- package/dist/cjs/map-view.e031052e.js.map +1 -0
- package/dist/esm/{container.bba0b16c.js → container.1c2aa81d.js} +5 -5
- package/dist/esm/{container.bba0b16c.js.map → container.1c2aa81d.js.map} +1 -1
- package/dist/esm/{controls.42c750c4.js → controls.8efb9074.js} +4 -4
- package/dist/esm/{controls.42c750c4.js.map → controls.8efb9074.js.map} +1 -1
- package/dist/esm/{dev.b2d9d35d.js → dev.3d88888b.js} +2 -2
- package/dist/esm/{dev.b2d9d35d.js.map → dev.3d88888b.js.map} +1 -1
- package/dist/esm/{header.a73b6e0a.js → header.a3da6906.js} +2 -2
- package/dist/esm/header.a3da6906.js.map +1 -0
- package/dist/esm/{helpers.fb1d7227.js → helpers.d32a342a.js} +20 -4
- package/dist/esm/helpers.d32a342a.js.map +1 -0
- package/dist/esm/index.d.ts +29 -14
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -8
- package/dist/esm/{location-info.5543bb05.js → location-info.4b39fdfc.js} +13 -3
- package/dist/esm/location-info.4b39fdfc.js.map +1 -0
- package/dist/esm/{location-panel.c620b13b.js → location-panel.c9942d88.js} +3 -3
- package/dist/esm/{location-panel.c620b13b.js.map → location-panel.c9942d88.js.map} +1 -1
- package/dist/esm/main.module.303f6d99.js.map +1 -1
- package/dist/esm/{main.module.f70e002b.js → main.module.504d756b.js} +4 -1
- package/dist/esm/main.module.504d756b.js.map +1 -0
- package/dist/esm/main.module.9c57cc95.js.map +1 -1
- package/dist/esm/{map-page.1da2d70c.js → map-page.660a1723.js} +8 -7
- package/dist/esm/map-page.660a1723.js.map +1 -0
- package/dist/esm/{map-view.1fc6297b.js → map-view.d1c5b113.js} +68 -40
- package/dist/esm/map-view.d1c5b113.js.map +1 -0
- package/dist/node/container.ab523076.js +2 -0
- package/dist/node/{container.053f798f.js.map → container.ab523076.js.map} +1 -1
- package/dist/node/{controls.6ec8e9ac.js → controls.511f309b.js} +2 -2
- package/dist/node/{controls.6ec8e9ac.js.map → controls.511f309b.js.map} +1 -1
- package/dist/node/{dev.4640438e.js → dev.709287ba.js} +2 -2
- package/dist/node/{dev.4640438e.js.map → dev.709287ba.js.map} +1 -1
- package/dist/node/{header.cf9ba12b.js → header.98a4cf12.js} +2 -2
- package/dist/node/{header.cf9ba12b.js.map → header.98a4cf12.js.map} +1 -1
- package/dist/node/helpers.6bda171f.js.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/location-info.db66c3fb.js +2 -0
- package/dist/node/location-info.db66c3fb.js.map +1 -0
- package/dist/node/{location-panel.2e422cc0.js → location-panel.dd1d2b37.js} +2 -2
- package/dist/node/{location-panel.2e422cc0.js.map → location-panel.dd1d2b37.js.map} +1 -1
- package/dist/node/main.module.7c928a6f.js +2 -0
- package/dist/node/main.module.7c928a6f.js.map +1 -0
- package/dist/node/main.module.91a06e96.css +2 -0
- package/dist/node/main.module.91a06e96.css.map +1 -0
- package/dist/node/{map-page.d0e099ab.js → map-page.a9602658.js} +2 -2
- package/dist/node/map-page.a9602658.js.map +1 -0
- package/dist/node/{map-view.9dc96288.js → map-view.663640da.js} +2 -2
- package/dist/node/map-view.663640da.js.map +1 -0
- package/package.json +5 -5
- package/src/dev/map-page.ts +2 -10
- package/src/helpers.ts +31 -4
- package/src/location-info/index.ts +15 -6
- package/src/location-panel/header.ts +5 -3
- package/src/main.module.sass +13 -6
- package/src/map-view.ts +92 -45
- package/dist/cjs/header.af864bde.js.map +0 -1
- package/dist/cjs/helpers.0f72ddaf.js.map +0 -1
- package/dist/cjs/location-info.92e70042.js.map +0 -1
- package/dist/cjs/main.module.62939ea7.js.map +0 -1
- package/dist/cjs/main.module.f57e27f2.css.map +0 -1
- package/dist/cjs/map-page.1e1970d8.js.map +0 -1
- package/dist/cjs/map-view.61e50e18.js.map +0 -1
- package/dist/esm/header.a73b6e0a.js.map +0 -1
- package/dist/esm/helpers.fb1d7227.js.map +0 -1
- package/dist/esm/location-info.5543bb05.js.map +0 -1
- package/dist/esm/main.module.f70e002b.js.map +0 -1
- package/dist/esm/map-page.1da2d70c.js.map +0 -1
- package/dist/esm/map-view.1fc6297b.js.map +0 -1
- package/dist/node/container.053f798f.js +0 -2
- package/dist/node/location-info.9f59aad3.js +0 -2
- package/dist/node/location-info.9f59aad3.js.map +0 -1
- package/dist/node/main.module.24615279.js +0 -2
- package/dist/node/main.module.24615279.js.map +0 -1
- package/dist/node/main.module.65e40c2e.css +0 -2
- package/dist/node/main.module.65e40c2e.css.map +0 -1
- package/dist/node/map-page.d0e099ab.js.map +0 -1
- package/dist/node/map-view.9dc96288.js.map +0 -1
|
@@ -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,SC+BU,AAAA,AAAA,EAAA,GAAM,MAAM,CAAC,EAAA","sources":["<anon>","packages/map-interface/src/map-view.ts"],"sourcesContent":["require(\"./main.module.7c928a6f.js\");\nrequire(\"./main.module.91a06e96.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 const map = new (0, ($parcel$interopDefault($iE1eH$mapboxgl))).Map({\n container: container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest\n });\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) // If no map positioning information is provided, we use the default\n _mapPosition = $8c5236898eee97dc$var$defaultMapPosition;\n // set initial map position\n if (_mapPosition != null) (0, $iE1eH$macrostratmapboxutils.setMapPosition)(map, _mapPosition);\n return map;\n}\nconst $8c5236898eee97dc$var$defaultMapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000\n }\n};\nfunction $8c5236898eee97dc$export$ab1e7a67d6ec5ad8(props) {\n let { terrainSourceID: terrainSourceID } = props;\n const { enableTerrain: enableTerrain = true, style: style, mapPosition: mapPosition, initializeMap: initializeMap = $8c5236898eee97dc$var$defaultInitializeMap, children: children, mapboxToken: mapboxToken, accessToken: // Deprecated\n accessToken, infoMarkerPosition: infoMarkerPosition, transformRequest: transformRequest, projection: projection, onMapLoaded: onMapLoaded = null, onStyleLoaded: onStyleLoaded = null, onMapMoved: onMapMoved = null, standalone: standalone = false, overlayStyles: overlayStyles, transformStyle: transformStyle, ...rest } = props;\n if (enableTerrain) terrainSourceID ?? (terrainSourceID = \"mapbox-3d-dem\");\n const _mapboxToken = mapboxToken ?? accessToken;\n if (_mapboxToken != null) (0, ($parcel$interopDefault($iE1eH$mapboxgl))).accessToken = _mapboxToken;\n const dispatch = (0, $iE1eH$macrostratmapboxreact.useMapDispatch)();\n let mapRef = (0, $iE1eH$macrostratmapboxreact.useMapRef)();\n const ref = (0, $iE1eH$react.useRef)();\n const parentRef = (0, $iE1eH$react.useRef)();\n const [baseStyle, setBaseStyle] = (0, $iE1eH$react.useState)(null);\n const isStyleLoaded = (0, $iE1eH$macrostratmapboxreact.useMapStatus)((state)=>state.isStyleLoaded);\n (0, $iE1eH$react.useEffect)(()=>{\n /** Manager to update map style */ if (baseStyle == null) return;\n let map = mapRef.current;\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */ // We either get the map position directly from the map or from props\n const estMapPosition = map == null ? mapPosition : (0, $iE1eH$macrostratmapboxutils.getMapPosition)(map);\n const { mapUse3D: mapUse3D } = (0, $iE1eH$macrostratmapboxutils.mapViewInfo)(estMapPosition);\n let newStyle = baseStyle;\n const overlayStyles = props.overlayStyles ?? [];\n if (overlayStyles.length > 0) newStyle = (0, $iE1eH$macrostratmapboxutils.mergeStyles)(newStyle, ...overlayStyles);\n if (mapUse3D) {\n // We can update the style with terrain layers immediately\n const terrainStyle = (0, $iE1eH$macrostratmapboxreact.getTerrainLayerForStyle)(newStyle, terrainSourceID);\n newStyle = (0, $iE1eH$macrostratmapboxutils.mergeStyles)(newStyle, terrainStyle);\n }\n if (transformStyle != null) newStyle = transformStyle(newStyle);\n if (map != null) {\n console.log(\"Setting style\", newStyle);\n dispatch({\n type: \"set-style-loaded\",\n payload: false\n });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection: projection,\n mapPosition: mapPosition,\n transformRequest: transformRequest,\n ...rest\n });\n dispatch({\n type: \"set-map\",\n payload: map\n });\n map.setPadding((0, $R3my3.getMapPadding)(ref, parentRef), {\n animate: false\n });\n onMapLoaded?.(map);\n }\n }, [\n baseStyle,\n overlayStyles,\n transformStyle\n ]);\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */ (0, $iE1eH$react.useEffect)(()=>{\n if (isStyleLoaded) return;\n const interval = setInterval(()=>{\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({\n type: \"set-style-loaded\",\n payload: true\n });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return ()=>clearInterval(interval);\n }, [\n isStyleLoaded\n ]);\n (0, $iE1eH$macrostratuicomponents.useAsyncEffect)(async ()=>{\n /** Manager to update map style */ let newStyle;\n if (typeof style === \"string\") newStyle = await (0, $iE1eH$macrostratmapboxutils.getMapboxStyle)(style, {\n access_token: (0, ($parcel$interopDefault($iE1eH$mapboxgl))).accessToken\n });\n else newStyle = style;\n setBaseStyle(newStyle);\n }, [\n style\n ]);\n const _computedMapPosition = (0, $iE1eH$macrostratmapboxreact.useMapPosition)();\n const { mapUse3D: mapUse3D, mapIsRotated: mapIsRotated } = (0, $iE1eH$macrostratmapboxutils.mapViewInfo)(_computedMapPosition);\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n const className = (0, ($parcel$interopDefault($iE1eH$classnames)))({\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false\n }, `${_projection}-projection`);\n const parentClassName = (0, ($parcel$interopDefault($iE1eH$classnames)))({\n standalone: standalone\n });\n return $8c5236898eee97dc$var$h(\"div.map-view-container.main-view\", {\n ref: parentRef,\n className: parentClassName\n }, [\n $8c5236898eee97dc$var$h(\"div.mapbox-map#map\", {\n ref: ref,\n className: className\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapLoadingReporter), {\n ignoredSources: [\n \"elevationMarker\",\n \"crossSectionEndpoints\"\n ]\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapMovedReporter), {\n onMapMoved: onMapMoved\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapResizeManager), {\n containerRef: ref\n }),\n $8c5236898eee97dc$var$h((0, $7CmOU.MapPaddingManager), {\n containerRef: ref,\n parentRef: parentRef,\n infoMarkerPosition: infoMarkerPosition\n }),\n $8c5236898eee97dc$var$h($8c5236898eee97dc$export$cee395a8a2a00b29, {\n mapUse3D: mapUse3D,\n terrainSourceID: terrainSourceID,\n style: style\n }),\n children\n ]);\n}\nfunction $8c5236898eee97dc$export$cee395a8a2a00b29({ mapUse3D: mapUse3D, terrainSourceID: terrainSourceID, style: style }) {\n (0, $iE1eH$macrostratmapboxreact.use3DTerrain)(mapUse3D, terrainSourceID);\n return null;\n}\n\n\n//# sourceMappingURL=map-view.663640da.js.map\n","import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.Style>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n // We either get the map position directly from the map or from props\n const estMapPosition: MapPosition | null =\n map == null ? mapPosition : getMapPosition(map);\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n let newStyle: mapboxgl.Style = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n if (mapUse3D) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n console.log(\"Setting style\", newStyle);\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, transformStyle]);\n\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.Style;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`\n );\n\n const parentClassName = classNames({\n standalone,\n });\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\n ]\n );\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.Style | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":["require","$iE1eH$macrostrathyper","$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.663640da.js.map","sourceRoot":"../../../../"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/map-interface",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Map interface for Macrostrat",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"node": "dist/node/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@blueprintjs/core": "^5.0.0",
|
|
12
|
-
"@macrostrat/color-utils": "^1.0
|
|
12
|
+
"@macrostrat/color-utils": "^1.1.0",
|
|
13
13
|
"@macrostrat/hyper": "^3.0.6",
|
|
14
|
-
"@macrostrat/mapbox-react": "^2.
|
|
15
|
-
"@macrostrat/mapbox-utils": "^1.
|
|
16
|
-
"@macrostrat/ui-components": "^4.
|
|
14
|
+
"@macrostrat/mapbox-react": "^2.6.0",
|
|
15
|
+
"@macrostrat/mapbox-utils": "^1.5.0",
|
|
16
|
+
"@macrostrat/ui-components": "^4.2.0",
|
|
17
17
|
"@mapbox/tilebelt": "^2.0.0",
|
|
18
18
|
"classnames": "^2.5.1",
|
|
19
19
|
"d3-array": "^3.2.4",
|
package/src/dev/map-page.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { useCallback, useState, useEffect } from "react";
|
|
|
7
7
|
import { buildInspectorStyle } from "./xray";
|
|
8
8
|
import { MapAreaContainer, PanelCard } from "../container";
|
|
9
9
|
import { FloatingNavbar, MapLoadingButton } from "../context-panel";
|
|
10
|
-
import { MapMarker } from "../helpers";
|
|
10
|
+
import { MapMarker, useBasicMapStyle } from "../helpers";
|
|
11
11
|
import { LocationPanel } from "../location-panel";
|
|
12
12
|
import { MapView } from "../map-view";
|
|
13
13
|
import styles from "./main.module.sass";
|
|
@@ -67,15 +67,7 @@ export function MapInspectorV2({
|
|
|
67
67
|
mapboxgl.accessToken = mapboxToken;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
style ??= isEnabled
|
|
72
|
-
? "mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true"
|
|
73
|
-
: "mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true";
|
|
74
|
-
} else {
|
|
75
|
-
style ??= isEnabled
|
|
76
|
-
? "mapbox://styles/mapbox/dark-v10"
|
|
77
|
-
: "mapbox://styles/mapbox/light-v10";
|
|
78
|
-
}
|
|
70
|
+
style ??= useBasicMapStyle({ styleType });
|
|
79
71
|
|
|
80
72
|
const [isOpen, setOpen] = useState(false);
|
|
81
73
|
|
package/src/helpers.ts
CHANGED
|
@@ -184,9 +184,36 @@ export function MapMarker({ position, setPosition, centerMarker = true }) {
|
|
|
184
184
|
return null;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
export function
|
|
187
|
+
export function useBasicMapStyle(
|
|
188
|
+
opts: {
|
|
189
|
+
styleType?: "macrostrat" | "standard";
|
|
190
|
+
} = {}
|
|
191
|
+
) {
|
|
192
|
+
const { styleType } = opts;
|
|
188
193
|
const inDarkMode = useInDarkMode();
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
|
|
195
|
+
const props = useMemo(() => {
|
|
196
|
+
return { styleType, inDarkMode };
|
|
197
|
+
}, [styleType, inDarkMode]);
|
|
198
|
+
|
|
199
|
+
return getBasicMapStyle(props);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function getBasicMapStyle(opts: {
|
|
203
|
+
styleType?: "macrostrat" | "standard";
|
|
204
|
+
inDarkMode?: boolean;
|
|
205
|
+
}) {
|
|
206
|
+
const { styleType = "macrostrat", inDarkMode = false } = opts ?? {};
|
|
207
|
+
|
|
208
|
+
if (styleType == "macrostrat") {
|
|
209
|
+
return inDarkMode
|
|
210
|
+
? "mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true"
|
|
211
|
+
: "mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true";
|
|
212
|
+
} else {
|
|
213
|
+
return inDarkMode
|
|
214
|
+
? "mapbox://styles/mapbox/dark-v10"
|
|
215
|
+
: "mapbox://styles/mapbox/light-v10";
|
|
216
|
+
}
|
|
192
217
|
}
|
|
218
|
+
|
|
219
|
+
export const useBasicStylePair = useBasicMapStyle;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
normalizeLng,
|
|
6
6
|
} from "@macrostrat/mapbox-utils";
|
|
7
7
|
import { formatValue } from "./utils";
|
|
8
|
+
import { LngLat } from "mapbox-gl";
|
|
8
9
|
|
|
9
10
|
export * from "./hash-string";
|
|
10
11
|
|
|
@@ -29,12 +30,12 @@ export function DegreeCoord(props) {
|
|
|
29
30
|
|
|
30
31
|
export interface LngLatProps {
|
|
31
32
|
/** Map position */
|
|
32
|
-
position:
|
|
33
|
+
position: mapboxgl.LngLatLike | null;
|
|
33
34
|
className?: string;
|
|
34
35
|
/** Zoom level (used to infer coordinate rounding if provided) */
|
|
35
|
-
zoom?: number
|
|
36
|
+
zoom?: number;
|
|
36
37
|
/** Number of decimal places to round coordinates to */
|
|
37
|
-
precision
|
|
38
|
+
precision?: number;
|
|
38
39
|
/** Function to format coordinates */
|
|
39
40
|
format?: (val: number, precision: number) => string;
|
|
40
41
|
}
|
|
@@ -46,11 +47,19 @@ export function LngLatCoords(props: LngLatProps) {
|
|
|
46
47
|
if (position == null) {
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
let lat: number;
|
|
52
|
+
let lng: number;
|
|
50
53
|
if (Array.isArray(position)) {
|
|
51
54
|
[lng, lat] = position;
|
|
52
|
-
} else {
|
|
53
|
-
|
|
55
|
+
} else if (position instanceof LngLat) {
|
|
56
|
+
[lng, lat] = position.toArray();
|
|
57
|
+
} else if ("lng" in position) {
|
|
58
|
+
lat = position.lat;
|
|
59
|
+
lng = position.lng;
|
|
60
|
+
} else if ("lon" in position) {
|
|
61
|
+
lat = position.lat;
|
|
62
|
+
lng = position.lon;
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
if (zoom != null && format == null && precision == null) {
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
isCentered,
|
|
10
10
|
} from "@macrostrat/mapbox-react";
|
|
11
11
|
import classNames from "classnames";
|
|
12
|
+
import type { ReactNode } from "react";
|
|
13
|
+
import type { LngLatBounds, LngLatLike } from "mapbox-gl";
|
|
12
14
|
|
|
13
15
|
const h = hyper.styled(styles);
|
|
14
16
|
|
|
@@ -70,13 +72,13 @@ function CopyLinkButton({ itemName, children, onClick, ...rest }) {
|
|
|
70
72
|
|
|
71
73
|
export interface InfoDrawerHeaderProps {
|
|
72
74
|
onClose?: () => void;
|
|
73
|
-
position?:
|
|
75
|
+
position?: LngLatLike;
|
|
74
76
|
zoom?: number;
|
|
75
77
|
elevation?: number;
|
|
76
78
|
showCopyPositionButton?: boolean;
|
|
77
|
-
bounds?:
|
|
79
|
+
bounds?: LngLatBounds;
|
|
78
80
|
fixedHeight?: boolean;
|
|
79
|
-
children?:
|
|
81
|
+
children?: ReactNode;
|
|
80
82
|
className?: string;
|
|
81
83
|
}
|
|
82
84
|
|
package/src/main.module.sass
CHANGED
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
& > *
|
|
62
62
|
flex: 1
|
|
63
63
|
|
|
64
|
+
|
|
64
65
|
.map-control-stack
|
|
65
66
|
display: flex
|
|
66
67
|
flex-direction: column
|
|
@@ -89,6 +90,9 @@
|
|
|
89
90
|
flex-grow: 1
|
|
90
91
|
position: relative
|
|
91
92
|
overflow: hidden
|
|
93
|
+
&.standalone
|
|
94
|
+
height: 100%
|
|
95
|
+
width: 100%
|
|
92
96
|
|
|
93
97
|
.mapbox-map
|
|
94
98
|
position: absolute
|
|
@@ -102,6 +106,13 @@
|
|
|
102
106
|
position: absolute
|
|
103
107
|
|
|
104
108
|
|
|
109
|
+
/** These styles seem to help with weird map zooming behavior */
|
|
110
|
+
:global(.mapboxgl-canvas), :global(.mapboxgl-canvas-container)
|
|
111
|
+
position: relative
|
|
112
|
+
left: 0
|
|
113
|
+
top: 0
|
|
114
|
+
|
|
115
|
+
|
|
105
116
|
.context-panel-holder > :global(.bp5-card)
|
|
106
117
|
padding: 10px
|
|
107
118
|
background-color: var(--panel-background-color)
|
|
@@ -376,7 +387,8 @@
|
|
|
376
387
|
/* Make map fill page rather than containing div,
|
|
377
388
|
by unsetting map position */
|
|
378
389
|
// We should move this to another file.
|
|
379
|
-
|
|
390
|
+
|
|
391
|
+
.map-view-container:not(.standalone)
|
|
380
392
|
position: unset
|
|
381
393
|
|
|
382
394
|
|
|
@@ -440,11 +452,6 @@
|
|
|
440
452
|
.context-stack .spacer
|
|
441
453
|
min-height: 1em
|
|
442
454
|
|
|
443
|
-
/* Make map fill page rather than containing div,
|
|
444
|
-
by unsetting map position */
|
|
445
|
-
.map-view-container
|
|
446
|
-
position: unset
|
|
447
|
-
|
|
448
455
|
/** CSS Transitions **/
|
|
449
456
|
|
|
450
457
|
.map-container
|
package/src/map-view.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
useMapRef,
|
|
4
4
|
useMapDispatch,
|
|
5
5
|
useMapPosition,
|
|
6
|
-
setup3DTerrain,
|
|
7
6
|
use3DTerrain,
|
|
8
|
-
|
|
7
|
+
getTerrainLayerForStyle,
|
|
8
|
+
useMapStatus,
|
|
9
9
|
} from "@macrostrat/mapbox-react";
|
|
10
10
|
import {
|
|
11
11
|
mapViewInfo,
|
|
@@ -13,10 +13,11 @@ import {
|
|
|
13
13
|
setMapPosition,
|
|
14
14
|
getMapPosition,
|
|
15
15
|
getMapboxStyle,
|
|
16
|
+
mergeStyles,
|
|
16
17
|
} from "@macrostrat/mapbox-utils";
|
|
17
18
|
import classNames from "classnames";
|
|
18
19
|
import mapboxgl from "mapbox-gl";
|
|
19
|
-
import { useEffect, useRef } from "react";
|
|
20
|
+
import { useEffect, useRef, useState } from "react";
|
|
20
21
|
import styles from "./main.module.sass";
|
|
21
22
|
import {
|
|
22
23
|
MapLoadingReporter,
|
|
@@ -49,6 +50,14 @@ export interface MapViewProps extends MapboxCoreOptions {
|
|
|
49
50
|
onMapLoaded?: (map: mapboxgl.Map) => void;
|
|
50
51
|
onStyleLoaded?: (map: mapboxgl.Map) => void;
|
|
51
52
|
onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;
|
|
53
|
+
/** This map sets its own viewport, rather than being positioned by a parent.
|
|
54
|
+
* This is a hack to ensure that the map can overflow its "safe area" when false */
|
|
55
|
+
standalone?: boolean;
|
|
56
|
+
/** Overlay styles to apply to the map: a list of mapbox style objects or fragments to
|
|
57
|
+
* overlay on top of the main map style at runtime */
|
|
58
|
+
overlayStyles?: Partial<mapboxgl.Style>[];
|
|
59
|
+
/** A function to transform the map style before it is loaded */
|
|
60
|
+
transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
export interface MapboxOptionsExt extends MapboxCoreOptions {
|
|
@@ -57,12 +66,10 @@ export interface MapboxOptionsExt extends MapboxCoreOptions {
|
|
|
57
66
|
|
|
58
67
|
function defaultInitializeMap(container, args: MapboxOptionsExt = {}) {
|
|
59
68
|
const { mapPosition, ...rest } = args;
|
|
60
|
-
console.log("Initializing map (default)", args);
|
|
61
69
|
|
|
62
70
|
const map = new mapboxgl.Map({
|
|
63
71
|
container,
|
|
64
72
|
maxZoom: 18,
|
|
65
|
-
//maxTileCacheSize: 0,
|
|
66
73
|
logoPosition: "bottom-left",
|
|
67
74
|
trackResize: true,
|
|
68
75
|
antialias: true,
|
|
@@ -70,12 +77,17 @@ function defaultInitializeMap(container, args: MapboxOptionsExt = {}) {
|
|
|
70
77
|
...rest,
|
|
71
78
|
});
|
|
72
79
|
|
|
80
|
+
let _mapPosition = mapPosition;
|
|
81
|
+
if (_mapPosition == null && rest.center == null && rest.bounds == null) {
|
|
82
|
+
// If no map positioning information is provided, we use the default
|
|
83
|
+
_mapPosition = defaultMapPosition;
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
// set initial map position
|
|
74
|
-
if (
|
|
75
|
-
setMapPosition(map,
|
|
87
|
+
if (_mapPosition != null) {
|
|
88
|
+
setMapPosition(map, _mapPosition);
|
|
76
89
|
}
|
|
77
90
|
|
|
78
|
-
//setMapPosition(map, mapPosition);
|
|
79
91
|
return map;
|
|
80
92
|
}
|
|
81
93
|
|
|
@@ -92,7 +104,7 @@ export function MapView(props: MapViewProps) {
|
|
|
92
104
|
const {
|
|
93
105
|
enableTerrain = true,
|
|
94
106
|
style,
|
|
95
|
-
mapPosition
|
|
107
|
+
mapPosition,
|
|
96
108
|
initializeMap = defaultInitializeMap,
|
|
97
109
|
children,
|
|
98
110
|
mapboxToken,
|
|
@@ -104,6 +116,9 @@ export function MapView(props: MapViewProps) {
|
|
|
104
116
|
onMapLoaded = null,
|
|
105
117
|
onStyleLoaded = null,
|
|
106
118
|
onMapMoved = null,
|
|
119
|
+
standalone = false,
|
|
120
|
+
overlayStyles,
|
|
121
|
+
transformStyle,
|
|
107
122
|
...rest
|
|
108
123
|
} = props;
|
|
109
124
|
if (enableTerrain) {
|
|
@@ -121,9 +136,12 @@ export function MapView(props: MapViewProps) {
|
|
|
121
136
|
const ref = useRef<HTMLDivElement>();
|
|
122
137
|
const parentRef = useRef<HTMLDivElement>();
|
|
123
138
|
|
|
124
|
-
|
|
139
|
+
const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);
|
|
140
|
+
const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
125
143
|
/** Manager to update map style */
|
|
126
|
-
if (
|
|
144
|
+
if (baseStyle == null) return;
|
|
127
145
|
let map = mapRef.current;
|
|
128
146
|
|
|
129
147
|
/** If we can, we try to update the map style with terrain information
|
|
@@ -136,25 +154,29 @@ export function MapView(props: MapViewProps) {
|
|
|
136
154
|
// We either get the map position directly from the map or from props
|
|
137
155
|
const estMapPosition: MapPosition | null =
|
|
138
156
|
map == null ? mapPosition : getMapPosition(map);
|
|
139
|
-
let newStyle = style;
|
|
140
157
|
const { mapUse3D } = mapViewInfo(estMapPosition);
|
|
141
158
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
159
|
+
let newStyle: mapboxgl.Style = baseStyle;
|
|
160
|
+
|
|
161
|
+
const overlayStyles = props.overlayStyles ?? [];
|
|
162
|
+
|
|
163
|
+
if (overlayStyles.length > 0) {
|
|
164
|
+
newStyle = mergeStyles(newStyle, ...overlayStyles);
|
|
149
165
|
}
|
|
150
166
|
|
|
151
167
|
if (mapUse3D) {
|
|
152
168
|
// We can update the style with terrain layers immediately
|
|
153
|
-
|
|
169
|
+
const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);
|
|
170
|
+
newStyle = mergeStyles(newStyle, terrainStyle);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (transformStyle != null) {
|
|
174
|
+
newStyle = transformStyle(newStyle);
|
|
154
175
|
}
|
|
155
176
|
|
|
156
177
|
if (map != null) {
|
|
157
178
|
console.log("Setting style", newStyle);
|
|
179
|
+
dispatch({ type: "set-style-loaded", payload: false });
|
|
158
180
|
map.setStyle(newStyle);
|
|
159
181
|
} else {
|
|
160
182
|
console.log("Initializing map", newStyle);
|
|
@@ -169,23 +191,36 @@ export function MapView(props: MapViewProps) {
|
|
|
169
191
|
map.setPadding(getMapPadding(ref, parentRef), { animate: false });
|
|
170
192
|
onMapLoaded?.(map);
|
|
171
193
|
}
|
|
194
|
+
}, [baseStyle, overlayStyles, transformStyle]);
|
|
172
195
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
196
|
+
/** Check back every 0.1 seconds to see if the map has loaded.
|
|
197
|
+
* We do it this way because mapboxgl loading events are unreliable */
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (isStyleLoaded) return;
|
|
200
|
+
const interval = setInterval(() => {
|
|
201
|
+
const map = mapRef.current;
|
|
202
|
+
if (map == null) return;
|
|
203
|
+
if (map.isStyleLoaded()) {
|
|
204
|
+
// Wait a tick before setting the style loaded state
|
|
205
|
+
dispatch({ type: "set-style-loaded", payload: true });
|
|
206
|
+
onStyleLoaded?.(map);
|
|
207
|
+
clearInterval(interval);
|
|
208
|
+
}
|
|
209
|
+
}, 50);
|
|
210
|
+
return () => clearInterval(interval);
|
|
211
|
+
}, [isStyleLoaded]);
|
|
178
212
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
213
|
+
useAsyncEffect(async () => {
|
|
214
|
+
/** Manager to update map style */
|
|
215
|
+
let newStyle: mapboxgl.Style;
|
|
216
|
+
if (typeof style === "string") {
|
|
217
|
+
newStyle = await getMapboxStyle(style, {
|
|
218
|
+
access_token: mapboxgl.accessToken,
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
newStyle = style;
|
|
184
222
|
}
|
|
185
|
-
|
|
186
|
-
return () => {
|
|
187
|
-
map.off("style.load", loadCallback);
|
|
188
|
-
};
|
|
223
|
+
setBaseStyle(newStyle);
|
|
189
224
|
}, [style]);
|
|
190
225
|
|
|
191
226
|
const _computedMapPosition = useMapPosition();
|
|
@@ -202,17 +237,29 @@ export function MapView(props: MapViewProps) {
|
|
|
202
237
|
`${_projection}-projection`
|
|
203
238
|
);
|
|
204
239
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
240
|
+
const parentClassName = classNames({
|
|
241
|
+
standalone,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
return h(
|
|
245
|
+
"div.map-view-container.main-view",
|
|
246
|
+
{ ref: parentRef, className: parentClassName },
|
|
247
|
+
[
|
|
248
|
+
h("div.mapbox-map#map", { ref, className }),
|
|
249
|
+
h(MapLoadingReporter, {
|
|
250
|
+
ignoredSources: ["elevationMarker", "crossSectionEndpoints"],
|
|
251
|
+
}),
|
|
252
|
+
h(MapMovedReporter, { onMapMoved }),
|
|
253
|
+
h(MapResizeManager, { containerRef: ref }),
|
|
254
|
+
h(MapPaddingManager, {
|
|
255
|
+
containerRef: ref,
|
|
256
|
+
parentRef,
|
|
257
|
+
infoMarkerPosition,
|
|
258
|
+
}),
|
|
259
|
+
h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),
|
|
260
|
+
children,
|
|
261
|
+
]
|
|
262
|
+
);
|
|
216
263
|
}
|
|
217
264
|
|
|
218
265
|
export function MapTerrainManager({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAE5B,SAAS,qCAAe,YAAE,QAAQ,UAAE,MAAM,gBAAE,eAA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B;IAGF,OAAO,wBACL,gCACA;QACE,WAAW,CAAA,GAAA,2CAAS,EAAE,WAAW;YAAE,gBAAgB;QAAY;IACjE,GACA;QACE;QACA;QACA,wBAAE;QACF,wBAAE,EAAE,CAAC,YAAY,MAAM,CAAA,GAAA,sCAAW,GAAG;sBACnC;kBACA;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,aAAa,MAAM,CAAA,GAAA,mCAAQ,GAAG;uBACjC;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,WAAW,MAAM,CAAA,GAAA,6BAAK,GAAG;YAC5B,SAAS;YACT,MAAM;YACN,SAAS;QACX;KACD;AAEL","sources":["packages/map-interface/src/location-panel/header.ts"],"sourcesContent":["import { Icon, Button } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useToaster } from \"@macrostrat/ui-components\";\nimport { LngLatCoords, Elevation } from \"../location-info\";\nimport {\n LocationFocusButton,\n useFocusState,\n isCentered,\n} from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\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?: mapboxgl.LngLat;\n zoom?: number;\n elevation?: number;\n showCopyPositionButton?: boolean;\n bounds?: mapboxgl.LngLatBounds;\n fixedHeight?: boolean;\n children?: React.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":"header.af864bde.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
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,YA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AW,gBAAE,eAAe,MAAM;IACtE,MAAM,SAAS,CAAA,GAAA,sCAAQ;IACvB,MAAM,YAAY,CAAA,GAAA,mBAAK,EAAE;IACzB,MAAM,gBAAgB,CAAA,GAAA,8CAAgB;IAEtC,CAAA,GAAA,sCAAW,EAAE,QAAQ,WAAW;IAEhC,CAAA,GAAA,sBAAQ,EAAE;QACR,MAAM,MAAM,OAAO,OAAO;QAC1B,IAAI,OAAO,QAAQ,eAAe,MAAM;QAExC,MAAM,iBAAiB,CAAC;YACtB,YAAY,MAAM,MAAM,EAAE,OAAO,OAAO,OAAO;YAC/C,wDAAwD;YACxD,IAAI,cACF,OAAO,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;IACd,MAAM,aAAa,CAAA,GAAA,2CAAY;IAC/B,OAAO,aACH,oCACA;AACN","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\nexport function MapLoadingReporter({\n ignoredSources,\n onMapLoading = null,\n onMapIdle = null,\n mapIsLoading,\n}) {\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 useBasicStylePair() {\n const inDarkMode = useInDarkMode();\n return inDarkMode\n ? \"mapbox://styles/mapbox/dark-v10\"\n : \"mapbox://styles/mapbox/light-v10\";\n}\n"],"names":[],"version":3,"file":"helpers.0f72ddaf.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,0CAAc,KAAK;IACjC,MAAM,SAAE,KAAK,QAAE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AAW,EAAE;gBACpB,QAAQ;oBAAC;oBAAK;iBAAI;2BAClB;wBACA;YACF;SACD;KACF;AACH;AAEO,SAAS,0CAAU,KAAK;IAC7B,iFAAiF,GACjF,MAAM,aAAE,SAAS,aAAE,SAAS,eAAE,cAAc,MAAM,GAAG;IACrD,IAAI,aAAa,MAAM,OAAO;IAC9B,OAAO,CAAA,GAAA,gDAAA,EAAE,iBAAiB;mBAAE;IAAU,GAAG;QACvC,CAAA,GAAA,gDAAA,EAAE,2CAAe;YAAE,OAAO;YAAW,MAAM;QAAI;QAC/C,CAAA,GAAA,gDAAA,EAAE,EAAE,CAAC,aAAa,kBAAkB;YAClC;YACA,CAAA,GAAA,gDAAA,EAAE,2CAAe;gBAAE,OAAO,CAAA,GAAA,yCAAW,EAAE;gBAAY,MAAM;YAAK;YAC9D;SACD;KACF;AACH","sources":["packages/map-interface/src/location-info/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n formatCoordForZoomLevel,\n metersToFeet,\n normalizeLng,\n} from \"@macrostrat/mapbox-utils\";\nimport { formatValue } from \"./utils\";\n\nexport * from \"./hash-string\";\n\nexport function ValueWithUnit(props) {\n const { value, unit } = props;\n return h(\"span.value-with-unit\", [\n h(\"span.value\", [value]),\n h(\"span.spacer\", [\" \"]),\n h(\"span.unit\", [unit]),\n ]);\n}\n\nexport function DegreeCoord(props) {\n const { value, labels, precision = 3, format = formatValue } = props;\n const direction = value < 0 ? labels[1] : labels[0];\n\n return h(ValueWithUnit, {\n value: format(Math.abs(value), precision) + \"°\",\n unit: direction,\n });\n}\n\nexport interface LngLatProps {\n /** Map position */\n position: [number, number] | { lat: number; lng: number };\n className?: string;\n /** Zoom level (used to infer coordinate rounding if provided) */\n zoom?: number | null;\n /** Number of decimal places to round coordinates to */\n precision: number | null;\n /** Function to format coordinates */\n format?: (val: number, precision: number) => string;\n}\n\nexport function LngLatCoords(props: LngLatProps) {\n /** Formatted geographic coordinates */\n const { position, className, precision, zoom } = props;\n let { format } = props;\n if (position == null) {\n return null;\n }\n let lat, lng;\n if (Array.isArray(position)) {\n [lng, lat] = position;\n } else {\n ({ lat, lng } = position);\n }\n\n if (zoom != null && format == null && precision == null) {\n format = (val, _) => formatCoordForZoomLevel(val, zoom);\n }\n\n return h(\"div.lnglat-container\", { className }, [\n h(\"span.lnglat\", [\n h(DegreeCoord, {\n value: lat,\n labels: [\"N\", \"S\"],\n precision,\n format,\n }),\n \", \",\n h(DegreeCoord, {\n value: normalizeLng(lng),\n labels: [\"E\", \"W\"],\n precision,\n format,\n }),\n ]),\n ]);\n}\n\nexport function Elevation(props) {\n /** Renders an elevation value in meters and a parenthetical conversion to feet. */\n const { elevation, className, includeFeet = true } = props;\n if (elevation == null) return null;\n return h(\"div.elevation\", { className }, [\n h(ValueWithUnit, { value: elevation, unit: \"m\" }),\n h.if(includeFeet)(\"span.secondary\", [\n \" (\",\n h(ValueWithUnit, { value: metersToFeet(elevation), unit: \"ft\" }),\n \")\",\n ]),\n ]);\n}\n"],"names":[],"version":3,"file":"location-info.92e70042.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AApDA,4CAAkC;AAClC,2CAAwC;AACxC,4CAAuC;AACvC,4CAAiC;AACjC,4CAAoC;AACpC,4CAAmC;AACnC,4CAAmC;AACnC,4CAAqC;AACrC,4CAAkC;AAClC,4CAAkC;AAClC,4CAAsC;AACtC,4CAAiC;AACjC,4CAAuC;AACvC,4CAAwC;AACxC,4CAAsC;AACtC,4CAA6B;AAC7B,4CAA2B;AAC3B,4CAA+B;AAC/B,4CAAyC;AACzC,4CAA+B;AAC/B,4CAAkC;AAClC,4CAA8B;AAC9B,4CAAiC;AACjC,4CAAoC;AACpC,4CAAgC;AAChC,4CAA2B;AAC3B,4CAAqC;AACrC,2CAAgC;AAChC,4CAA4B;AAC5B,4CAA+B;AAC/B,2CAA8B;AAC9B,2CAAgC;AAChC,4CAAiC;AACjC,4CAA4B;AAC5B,4CAAwC;AACxC,4CAAiC;AACjC,4CAA+B;AAC/B,4CAAiC;AACjC,4CAAqC;AACrC,4CAA2C;AAC3C,4CAAuC;AACvC,4CAAiC;AACjC,4CAAsC;AACtC,4CAAuC;AACvC,4CAAqC;AACrC,4CAAiC;AACjC,4CAAmC;AACnC,4CAAuC;AACvC,4CAAwC;AACxC,4CAA0C;AAC1C,4CAAsC;AACtC,4CAAuC;AACvC,4CAAkC","sources":["packages/map-interface/src/main.module.sass"],"sourcesContent":[".map-container\n display: flex\n flex-direction: column\n position: relative\n width: 100%\n height: 100%\n overflow: hidden\n --map-panel-border-radius: 4px\n\n &.show-panel-outlines\n .map-view-container\n outline: 2px dotted dodgerblue\n\n &.fit-viewport\n height: 100vh\n width: 100vw\n /* mobile viewport bug fix */\n max-height: -webkit-fill-available\n\n // Compass display\n .compass-control\n display: none\n\n &.map-is-rotated\n .compass-control\n display: block\n\n .map-3d-control\n display: none\n\n &.map-3d-available .map-3d-control\n display: block\n\n &.map-is-rotated.map-3d-available .map-3d-control\n display: none\n\n .globe-control\n display: none\n\n svg\n color: var(--secondary-color)\n\n &.map-is-global .globe-control\n display: block\n\n &.detail-panel-open\n .zoom-control\n opacity: 0\n display: none\n\n &.detail-panel-fixed\n .detail-panel-holder\n & > *\n border-radius: unset\n\n.detail-panel-holder\n display: flex\n flex-direction: column\n min-height: 0\n\n & > *\n flex: 1\n\n.map-control-stack\n display: flex\n flex-direction: column\n width: 30em\n margin-left: -30em\n pointer-events: none\n\n.main-row\n flex: 1\n display: flex\n flex-direction: row\n position: relative\n max-height: 100%\n min-height: 0\n\n.map-ui\n flex: 1\n position: relative\n display: flex\n flex-direction: column\n max-height: 100%\n height: 100%\n box-shadow: 0 0 10px 4px var(--card-shadow-color)\n\n.map-view-container\n flex-grow: 1\n position: relative\n overflow: hidden\n\n.mapbox-map\n position: absolute\n top: 0\n bottom: 0\n left: 0\n right: 0\n\n &:global(.mapboxgl-map)\n // override the default mapbox position: relative in all cases\n position: absolute\n\n\n.context-panel-holder > :global(.bp5-card)\n padding: 10px\n background-color: var(--panel-background-color)\n\n.panel-card\n padding: 10px\n background-color: var(--panel-background-color)\n overflow: hidden\n border-radius: var(--map-panel-border-radius)\n\n & > :last-child\n margin-bottom: 0\n\n:global(.bp5-dark) .panel-card\n background-color: var(--panel-background-color)\n\n.context-stack\n & > div\n flex-shrink: 1\n\n & > .searchbar\n flex: 0\n\n.context-stack,\n.detail-stack\n z-index: 10\n max-height: 100%\n\n.panel-container\n display: flex\n flex-direction: column\n\n & > div\n pointer-events: all\n\n.panel-title\n font-size: 16px\n\n.spacer\n flex-grow: 1\n pointer-events: none\n\n.map-view-container\n flex-grow: 1\n position: relative\n overflow: hidden\n\n.searchbar-holder\n margin-bottom: 0.5em\n\n.right-panel\n width: 24em\n\n.buttons\n display: flex\n flex-direction: row\n flex: 1\n min-width: 0\n\n.tab-button\n flex-shrink: 1\n min-width: 40px\n overflow: hidden\n text-align: right\n\n & :global(.bp5-button-text)\n transition: all 0.2s\n transition-delay: 0.1s\n\n .menu-card.narrow-card .panel-header:not(.minimal) &:global(.bp5-active) ~ & :global(.bp5-button-text)\n width: 0\n opacity: 0\n margin-left: -7px\n\n .context-panel-leave .menu-card .panel-header & :global(.bp5-button-text)\n opacity: 0\n width: 0\n\n.narrow-card.narrow-enter .panel-header .buttons\n margin-right: -500px\n\n.panel-header.minimal .tab-button:not(:hover):not(:global(.bp5-active))\n padding-left: 0\n padding-right: 0\n min-width: 30px\n width: 30px\n\n.panel-header.minimal .tab-button:not(:hover) :global(.bp5-button-text)\n width: 0\n opacity: 0\n margin-left: -7px\n\n.menu-group\n margin-bottom: 0.5em\n margin-top: 0.2em\n\n.menu-card :global .bp5-text ul,\n.menu-card :global .text-panel ul\n padding-left: 1em\n\n.menu-content\n display: flex\n flex-direction: column\n margin-bottom: -8px\n\n & .bp5-button-group\n margin-bottom: 4px\n\n & hr\n width: 100%\n\n:global\n .mapbox-map\n .mapbox-compass, .mapbox-3d\n display: none\n\n .mapboxgl-ctrl.mapbox-3d.mapbox-control\n width: unset\n\n .mapboxgl-ctrl.mapbox-3d.mapbox-control button\n width: unset\n padding-inline: 4px\n\n .mapboxgl-canvas-container\n width: 100%\n height: 100%\n\n .mapboxgl-ctrl.mapboxgl-ctrl-attrib\n background-color: var(--translucent-panel-background-color) !important\n\n .mapboxgl-ctrl.mapboxgl-ctrl-attrib a\n color: var(--text-color)\n\n .mapboxgl-marker svg path\n fill: var(--panel-background-color) !important\n\n .mapboxgl-marker svg circle\n fill: var(--secondary-color) !important\n\n .mapbox-control.mapbox-zoom\n background: var(--translucent-panel-background-inner)\n\n .mapbox-control.mapbox-zoom svg\n fill: var(--text-color) !important\n\n .mapboxgl-ctrl-logo\n transform: scale(0.9) translate(-8px, 2px)\n\n .bp5-dark\n .mapboxgl-ctrl-group\n background-color: var(--panel-background-color)\n\n .mapboxgl-ctrl-logo\n filter: invert(100%)\n\n .mapboxgl-ctrl-group button + button\n border-top: 1px solid var(--panel-rule-color) !important\n\n .bp5-dark .mapboxgl-ctrl-group .mapboxgl-ctrl-icon\n filter: invert(40%)\n\n .bp5-dark .mapboxgl-ctrl-group .mapboxgl-ctrl-icon:hover\n filter: invert(50%)\n\n .mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon\n filter: invert(40%)\n\n .mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon:hover\n filter: invert(50%)\n\n.detail-stack\n position: relative\n\n.detail-panel-container, .map-right-controls\n flex: 1\n\n\n.zoom-control\n transition: opacity 1s ease-in-out\n width: 30px\n position: absolute\n top: 0\n right: 0\n\n.map-controls\n display: flex\n flex-direction: row\n justify-content: right\n margin-bottom: 0\n gap: 0.5em\n\n :global(.map-control)\n & > :global(.bp5-button)\n padding: 0\n transform: translate(-3.5px, -3.5px)\n width: 22px !important\n\n\n.map-controls :global(.mapbox-control),\n.map-controls :global(.map-control-wrapper),\n.map-controls :global(.map-control)\n max-height: 22px\n height: 22px\n border-radius: 4px\n background-color: var(--panel-background-color)\n box-shadow: 0 0 0 1px var(--card-shadow-color)\n\n.map-controls :global(.mapbox-control) button,\n.map-controls :global(.map-control-wrapper) button,\n.map-controls :global(.map-control) button\n max-height: 22px\n height: 22px\n width: 22px\n max-width: 22px\n background-position: center center\n padding: 0\n//background-color: var(--panel-background-color)\n//color: var(--text-color)\n\n//.map-controls :global(.mapbox-control) button:hover,\n//.map-controls :global(.map-control-wrapper) button:hover,\n//.map-controls .map-control button:hover\n// background-color: var(--panel-background-color) !important\n\n.map-controls .map-scale-control\n background: none\n box-shadow: none\n padding-top: 8px\n\n :global(.mapboxgl-ctrl-scale)\n background-color: var(--translucent-panel-background-color)\n border-color: var(--secondary-text-color)\n color: var(--secondary-text-color)\n\n// .map-container.detail-panel-fixed\n// right: 30em\n\n/* For mobile phones, we want to make the most of screen space,\n which in some cases means adding complications to the basic page. */\n@media only screen and (max-width: 768px)\n .map-container.detail-panel-enter .context-stack\n height: 0\n visibility: hidden\n transition: height 0.5s ease-in-out\n\n .detail-stack\n height: fit-content\n position: inherit\n max-height: 70%\n\n .infodrawer-stack\n max-height: 70%\n\n &:global(.exit-active)\n max-height: 0\n\n :global(.mapbox-control.mapbox-zoom)\n display: none\n\n .map-controls\n position: absolute\n top: -60px\n right: 10px\n\n .detail-panel\n border-radius: 0px\n\n\n/* Desktop styling is necessarily much more complicated than mobile\n to handle a two-column layout. */\n@media screen and (min-width: 768px)\n /* Make map fill page rather than containing div,\n by unsetting map position */\n // We should move this to another file.\n .map-view-container\n position: unset\n\n\n .map-ui\n flex-direction: row\n padding: 1em 1em 2em\n min-height: 80px\n gap: 0.5em\n\n .context-stack\n max-width: var(--map-context-stack-max-width, 34em)\n min-width: 14em\n transition: width 300ms ease\n padding-bottom: 0.5em\n width: var(--map-context-stack-width, 16em)\n margin-right: 0.5em\n display: flex\n flex-direction: column\n\n\n &.adaptive-width\n width: var(--map-context-stack-width, none)\n max-width: var(--map-context-stack-max-width, none)\n transition: width 300ms ease\n\n :global(.bp5-navbar)\n //height: unset\n //padding: 5px\n h1, h2, h3\n margin: 0\n\n & > .spacer\n flex-grow: 0\n\n .context-panel-holder\n min-height: 0\n position: relative\n\n & > div\n max-height: 100%\n\n .detail-stack\n width: var(--map-detail-stack-width, 30em)\n display: flex\n flex-direction: column\n\n .context-stack, .detail-stack\n pointer-events: none\n z-index: 10\n\n & > div\n pointer-events: all\n margin-bottom: 0.5em\n\n &:last-child\n margin-bottom: 0\n\n &.spacer\n pointer-events: none\n\n .context-stack .spacer\n min-height: 1em\n\n /* Make map fill page rather than containing div,\n by unsetting map position */\n .map-view-container\n position: unset\n\n/** CSS Transitions **/\n\n.map-container\n // Context panel\n .context-panel-holder\n pointer-events: none\n flex: 1\n\n & > div\n pointer-events: all\n transition: opacity 0.8s ease\n //, height 0.8s ease, max-height 0.8s ease, padding 0.8s ease\n\n &.context-panel-from .context-panel-holder > div\n opacity: 0\n\n &.context-panel-enter .context-panel-holder > div\n opacity: 1\n\n &.context-panel-leave .context-panel-holder > div\n opacity: 0\n\n // Detail panel (floating)\n &.detail-panel-floating\n // We assume that the relevant panel is the first child of the stack.\n &.detail-panel-from .detail-panel-holder\n opacity: 0\n\n &.detail-panel-enter .detail-panel-holder\n opacity: 1\n\n &.detail-panel-leave .detail-panel-holder\n opacity: 0\n\n .detail-panel\n transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease\n\n // TODO: these styles have not been evaluated for mobile\n &.detail-panel-fixed\n .map-ui\n transition: margin-right 0.8s ease\n\n .detail-stack\n transition: margin-right 0.8s ease\n\n &.detail-panel-from .detail-panel-holder\n margin-right: calc(-1 * var(--map-detail-stack-width, 30em))\n\n &.detail-panel-enter .detail-panel-holder\n margin-right: 0\n\n &.detail-panel-leave .detail-panel-holder\n margin-right: calc(-1 * var(--map-detail-stack-width, 30em))\n\n\n// The max-height transition is a bit jerky because of panel padding.\n// We could probably fix this by pulling the panel container itself into\n// the class.\n//max-height: 0\n//padding: 0i\n\n@media only screen and (max-width: 768px)\n .map-container .detail-stack\n transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease\n\n .map-container.detail-panel-from .detail-stack\n max-height: 0\n height: 0\n\n .map-container.detail-panel-leave .detail-stack\n max-height: 0\n\n .map-container.context-panel-from .context-panel\n max-height: 0\n height: 0\n\n .map-container.context-panel-leave\n .context-stack\n .context-panel-holder\n flex: 0\n\n .spacer\n flex: 1\n\n\n// Shift UI around to center elements if we're in the global view\n@media only screen and (min-width: 768px)\n .map-container.detail-panel-leave .map-view-container\n margin-right: -14em\n\n .map-container.map-is-global.detail-panel-leave .map-view-container\n margin-right: -30em\n\n .map-container.map-is-global.context-panel-leave .map-view-container\n margin-left: -16em\n"],"names":[],"version":3,"file":"main.module.62939ea7.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;AAUI;;;;AAGF;;;;;;AAOA;;;;AAIE;;;;AAGF;;;;AAGA;;;;AAGA;;;;AAME;;;;AAGF;;;;AAIE;;;;;AAME;;;;;;;;;;;;;;;;;;;;;;AAgBJ;;;;;;;;;AAOA;;;;;;;;;;AAYF;;;;;AAME;;;;AAGA;;;;;AAKE;;;;;;;;;;;AAQF;;;;AAGA;;;;AAGE;;;;AAEJ;;;;;AAKI;;;;;;;;;AAKJ;;;;;;;;;AAOE;;;;;;;;;;;;;;AASA;;;;;;;AAKA;;;;;;;;;;;;;;;;;AAYA;;;;;AAGF;;;;AAGE;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;;;AAKA;;;;;;;;AAKA;;;;;AAEF;;;;;AAIA;;;;AAGE;;;;AAGE;;;;AAGA;;;;AAIA;;;;AAGF;;;;AAGA;;;;;;;;AAME;;;;AAGA;;;;AAGA;;;;AAGA;;;;AAGA;;;;AAGA;;;;AAGA;;;;AAGA;;;;AAIE;;;;;;;;;;;;;;;;AAcJ;;;;;;;;;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;;;AAaF;EAAA;;;;;;EAME;;;;;;EAGF;;;;EAIE;;;;EAGA;;;;;;;;;;;;;;;;EA4BE;;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;;;;;EAoBJ;;;;;EAME;;;;EAIA;;;;;;;;;;;EASE;;;;;EAIA;;;;EAIA;;;;EAGE;;;;EAQF;;;;;AAKA;;;;;;;;;;AAQA;;;;AAGA;;;;AAGA;;;;;;;;;;;;;;;;AAeF;;;;AAQE;;;;AAGA;;;;;;;;;EAQF;;;;EAGA;;;;;EAOI;;;;EAGA;;;;;;;;;;;;;;AAaF;EACE;;;;EAGA;;;;EAGA","sources":["packages/map-interface/src/main.module.sass"],"sourcesContent":[".map-container\n display: flex\n flex-direction: column\n position: relative\n width: 100%\n height: 100%\n overflow: hidden\n --map-panel-border-radius: 4px\n\n &.show-panel-outlines\n .map-view-container\n outline: 2px dotted dodgerblue\n\n &.fit-viewport\n height: 100vh\n width: 100vw\n /* mobile viewport bug fix */\n max-height: -webkit-fill-available\n\n // Compass display\n .compass-control\n display: none\n\n &.map-is-rotated\n .compass-control\n display: block\n\n .map-3d-control\n display: none\n\n &.map-3d-available .map-3d-control\n display: block\n\n &.map-is-rotated.map-3d-available .map-3d-control\n display: none\n\n .globe-control\n display: none\n\n svg\n color: var(--secondary-color)\n\n &.map-is-global .globe-control\n display: block\n\n &.detail-panel-open\n .zoom-control\n opacity: 0\n display: none\n\n &.detail-panel-fixed\n .detail-panel-holder\n & > *\n border-radius: unset\n\n.detail-panel-holder\n display: flex\n flex-direction: column\n min-height: 0\n\n & > *\n flex: 1\n\n.map-control-stack\n display: flex\n flex-direction: column\n width: 30em\n margin-left: -30em\n pointer-events: none\n\n.main-row\n flex: 1\n display: flex\n flex-direction: row\n position: relative\n max-height: 100%\n min-height: 0\n\n.map-ui\n flex: 1\n position: relative\n display: flex\n flex-direction: column\n max-height: 100%\n height: 100%\n box-shadow: 0 0 10px 4px var(--card-shadow-color)\n\n.map-view-container\n flex-grow: 1\n position: relative\n overflow: hidden\n\n.mapbox-map\n position: absolute\n top: 0\n bottom: 0\n left: 0\n right: 0\n\n &:global(.mapboxgl-map)\n // override the default mapbox position: relative in all cases\n position: absolute\n\n\n.context-panel-holder > :global(.bp5-card)\n padding: 10px\n background-color: var(--panel-background-color)\n\n.panel-card, .panel-card:global(.bp5-card)\n padding: var(--panel-padding, 10px)\n background-color: var(--panel-background-color)\n overflow: hidden\n border-radius: var(--map-panel-border-radius)\n\n & > :last-child\n margin-bottom: 0\n\n:global(.bp5-dark) .panel-card\n background-color: var(--panel-background-color)\n\n.context-stack\n & > div\n flex-shrink: 1\n\n & > .searchbar\n flex: 0\n\n.context-stack,\n.detail-stack\n z-index: 10\n max-height: 100%\n\n.panel-container\n display: flex\n flex-direction: column\n\n & > div\n pointer-events: all\n\n.panel-title\n font-size: 16px\n\n.spacer\n flex-grow: 1\n pointer-events: none\n\n.map-view-container\n flex-grow: 1\n position: relative\n overflow: hidden\n\n.searchbar-holder\n margin-bottom: 0.5em\n\n.right-panel\n width: 24em\n\n.buttons\n display: flex\n flex-direction: row\n flex: 1\n min-width: 0\n\n.tab-button\n flex-shrink: 1\n min-width: 40px\n overflow: hidden\n text-align: right\n\n & :global(.bp5-button-text)\n transition: all 0.2s\n transition-delay: 0.1s\n\n .menu-card.narrow-card .panel-header:not(.minimal) &:global(.bp5-active) ~ & :global(.bp5-button-text)\n width: 0\n opacity: 0\n margin-left: -7px\n\n .context-panel-leave .menu-card .panel-header & :global(.bp5-button-text)\n opacity: 0\n width: 0\n\n.narrow-card.narrow-enter .panel-header .buttons\n margin-right: -500px\n\n.panel-header.minimal .tab-button:not(:hover):not(:global(.bp5-active))\n padding-left: 0\n padding-right: 0\n min-width: 30px\n width: 30px\n\n.panel-header.minimal .tab-button:not(:hover) :global(.bp5-button-text)\n width: 0\n opacity: 0\n margin-left: -7px\n\n.menu-group\n margin-bottom: 0.5em\n margin-top: 0.2em\n\n.menu-card :global .bp5-text ul,\n.menu-card :global .text-panel ul\n padding-left: 1em\n\n.menu-content\n display: flex\n flex-direction: column\n margin-bottom: -8px\n\n & .bp5-button-group\n margin-bottom: 4px\n\n & hr\n width: 100%\n\n:global\n .mapbox-map\n .mapbox-compass, .mapbox-3d\n display: none\n\n .mapboxgl-ctrl.mapbox-3d.mapbox-control\n width: unset\n\n .mapboxgl-ctrl.mapbox-3d.mapbox-control button\n width: unset\n padding-inline: 4px\n\n .mapboxgl-canvas-container\n width: 100%\n height: 100%\n\n .mapboxgl-ctrl.mapboxgl-ctrl-attrib\n background-color: var(--translucent-panel-background-color) !important\n\n .mapboxgl-ctrl.mapboxgl-ctrl-attrib a\n color: var(--text-color)\n\n .mapboxgl-marker svg path\n fill: var(--panel-background-color) !important\n\n .mapboxgl-marker svg circle\n fill: var(--secondary-color) !important\n\n .mapbox-control.mapbox-zoom\n background: var(--translucent-panel-background-inner)\n\n .mapbox-control.mapbox-zoom svg\n fill: var(--text-color) !important\n\n .mapboxgl-ctrl-logo\n transform: scale(0.9) translate(-8px, 2px)\n\n .bp5-dark\n .mapboxgl-ctrl-group\n background-color: var(--panel-background-color)\n\n .mapboxgl-ctrl-logo\n filter: invert(100%)\n\n .mapboxgl-ctrl-group button + button\n border-top: 1px solid var(--panel-rule-color) !important\n\n .bp5-dark .mapboxgl-ctrl-group .mapboxgl-ctrl-icon\n filter: invert(40%)\n\n .bp5-dark .mapboxgl-ctrl-group .mapboxgl-ctrl-icon:hover\n filter: invert(50%)\n\n .mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon\n filter: invert(40%)\n\n .mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon:hover\n filter: invert(50%)\n\n.detail-stack\n position: relative\n\n.detail-panel-container, .map-right-controls\n flex: 1\n\n\n.zoom-control\n transition: opacity 1s ease-in-out\n width: 30px\n position: absolute\n top: 0\n right: 0\n\n.map-controls\n display: flex\n flex-direction: row\n justify-content: right\n margin-bottom: 0\n gap: 0.5em\n\n :global(.map-control)\n & > :global(.bp5-button)\n padding: 0\n transform: translate(-3.5px, -3.5px)\n width: 22px !important\n\n\n.map-controls :global(.mapbox-control),\n.map-controls :global(.map-control-wrapper),\n.map-controls :global(.map-control)\n max-height: 22px\n height: 22px\n border-radius: 4px\n background-color: var(--panel-background-color)\n box-shadow: 0 0 0 1px var(--card-shadow-color)\n\n.map-controls :global(.mapbox-control) button,\n.map-controls :global(.map-control-wrapper) button,\n.map-controls :global(.map-control) button\n max-height: 22px\n height: 22px\n width: 22px\n max-width: 22px\n background-position: center center\n padding: 0\n//background-color: var(--panel-background-color)\n//color: var(--text-color)\n\n//.map-controls :global(.mapbox-control) button:hover,\n//.map-controls :global(.map-control-wrapper) button:hover,\n//.map-controls .map-control button:hover\n// background-color: var(--panel-background-color) !important\n\n.map-controls .map-scale-control\n background: none\n box-shadow: none\n padding-top: 8px\n\n :global(.mapboxgl-ctrl-scale)\n background-color: var(--translucent-panel-background-color)\n border-color: var(--secondary-text-color)\n color: var(--secondary-text-color)\n\n// .map-container.detail-panel-fixed\n// right: 30em\n\n/* For mobile phones, we want to make the most of screen space,\n which in some cases means adding complications to the basic page. */\n@media only screen and (max-width: 768px)\n .map-container.detail-panel-enter .context-stack\n height: 0\n visibility: hidden\n transition: height 0.5s ease-in-out\n\n .detail-stack\n height: fit-content\n position: inherit\n max-height: 70%\n\n .infodrawer-stack\n max-height: 70%\n\n &:global(.exit-active)\n max-height: 0\n\n :global(.mapbox-control.mapbox-zoom)\n display: none\n\n .map-controls\n position: absolute\n top: -60px\n right: 10px\n\n .detail-panel\n border-radius: 0px\n\n\n/* Desktop styling is necessarily much more complicated than mobile\n to handle a two-column layout. */\n@media screen and (min-width: 768px)\n /* Make map fill page rather than containing div,\n by unsetting map position */\n // We should move this to another file.\n .map-view-container\n position: unset\n\n\n .map-ui\n flex-direction: row\n padding: 1em 1em 2em\n min-height: 80px\n gap: 0.5em\n\n .context-stack\n max-width: var(--map-context-stack-max-width, 34em)\n min-width: 14em\n transition: width 300ms ease\n padding-bottom: 0.5em\n width: var(--map-context-stack-width, 16em)\n margin-right: 0.5em\n display: flex\n flex-direction: column\n\n\n &.adaptive-width\n width: var(--map-context-stack-width, none)\n max-width: var(--map-context-stack-max-width, none)\n transition: width 300ms ease\n\n :global(.bp5-navbar)\n //height: unset\n //padding: 5px\n h1, h2, h3\n margin: 0\n\n & > .spacer\n flex-grow: 0\n\n .context-panel-holder\n min-height: 0\n position: relative\n\n & > div\n max-height: 100%\n\n .detail-stack\n width: var(--map-detail-stack-width, 30em)\n display: flex\n flex-direction: column\n\n .context-stack, .detail-stack\n pointer-events: none\n z-index: 10\n\n & > div\n pointer-events: all\n margin-bottom: 0.5em\n\n &:last-child\n margin-bottom: 0\n\n &.spacer\n pointer-events: none\n\n .context-stack .spacer\n min-height: 1em\n\n /* Make map fill page rather than containing div,\n by unsetting map position */\n .map-view-container\n position: unset\n\n/** CSS Transitions **/\n\n.map-container\n // Context panel\n .context-panel-holder\n pointer-events: none\n flex: 1\n\n & > div\n pointer-events: all\n transition: opacity 0.8s ease\n //, height 0.8s ease, max-height 0.8s ease, padding 0.8s ease\n\n &.context-panel-from .context-panel-holder > div\n opacity: 0\n\n &.context-panel-enter .context-panel-holder > div\n opacity: 1\n\n &.context-panel-leave .context-panel-holder > div\n opacity: 0\n\n // Detail panel (floating)\n &.detail-panel-floating\n // We assume that the relevant panel is the first child of the stack.\n &.detail-panel-from .detail-panel-holder\n opacity: 0\n\n &.detail-panel-enter .detail-panel-holder\n opacity: 1\n\n &.detail-panel-leave .detail-panel-holder\n opacity: 0\n\n .detail-panel\n transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease\n\n // TODO: these styles have not been evaluated for mobile\n &.detail-panel-fixed\n .map-ui\n transition: margin-right 0.8s ease\n\n .detail-stack\n transition: margin-right 0.8s ease\n\n &.detail-panel-from .detail-panel-holder\n margin-right: calc(-1 * var(--map-detail-stack-width, 30em))\n\n &.detail-panel-enter .detail-panel-holder\n margin-right: 0\n\n &.detail-panel-leave .detail-panel-holder\n margin-right: calc(-1 * var(--map-detail-stack-width, 30em))\n\n\n// The max-height transition is a bit jerky because of panel padding.\n// We could probably fix this by pulling the panel container itself into\n// the class.\n//max-height: 0\n//padding: 0i\n\n@media only screen and (max-width: 768px)\n .map-container .detail-stack\n transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease\n\n .map-container.detail-panel-from .detail-stack\n max-height: 0\n height: 0\n\n .map-container.detail-panel-leave .detail-stack\n max-height: 0\n\n .map-container.context-panel-from .context-panel\n max-height: 0\n height: 0\n\n .map-container.context-panel-leave\n .context-stack\n .context-panel-holder\n flex: 0\n\n .spacer\n flex: 1\n\n\n// Shift UI around to center elements if we're in the global view\n@media only screen and (min-width: 768px)\n .map-container.detail-panel-leave .map-view-container\n margin-right: -14em\n\n .map-container.map-is-global.detail-panel-leave .map-view-container\n margin-right: -30em\n\n .map-container.map-is-global.context-panel-leave .map-view-container\n margin-left: -16em\n"],"names":[],"version":3,"file":"main.module.f57e27f2.css.map"}
|
|
@@ -1 +0,0 @@
|
|
|
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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 { Spacer, useDarkMode, useStoredState } from \"@macrostrat/ui-components\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useCallback, useState, useEffect } from \"react\";\nimport { buildInspectorStyle } from \"./xray\";\nimport { MapAreaContainer, PanelCard } from \"../container\";\nimport { FloatingNavbar, MapLoadingButton } from \"../context-panel\";\nimport { MapMarker } from \"../helpers\";\nimport { LocationPanel } from \"../location-panel\";\nimport { MapView } from \"../map-view\";\nimport styles from \"./main.module.sass\";\nimport { TileExtentLayer } from \"./tile-extent\";\nimport {\n FeaturePanel,\n FeatureSelectionHandler,\n TileInfo,\n} from \"./vector-tile-features\";\nimport { MapPosition } from \"@macrostrat/mapbox-utils\";\n\nexport const h = hyper.styled(styles);\n\nexport function MapInspectorV2({\n title = \"Map inspector\",\n headerElement = null,\n transformRequest = null,\n mapPosition = null,\n mapboxToken = null,\n overlayStyle = null,\n controls = null,\n children = null,\n style,\n bounds = null,\n focusedSource = null,\n focusedSourceTitle = null,\n fitViewport = true,\n styleType = \"macrostrat\",\n}: {\n headerElement?: React.ReactNode;\n transformRequest?: mapboxgl.TransformRequestFunction;\n title?: string;\n style?: mapboxgl.Style | string;\n controls?: React.ReactNode;\n children?: React.ReactNode;\n mapboxToken?: string;\n overlayStyle?: mapboxgl.Style | string;\n focusedSource?: string;\n focusedSourceTitle?: string;\n projection?: string;\n mapPosition?: MapPosition;\n bounds?: [number, number, number, number];\n fitViewport?: boolean;\n styleType?: \"standard\" | \"macrostrat\";\n}) {\n /* We apply a custom style to the panel container when we are interacting\n with the search bar, so that we can block map interactions until search\n bar focus is lost.\n We also apply a custom style when the infodrawer is open so we can hide\n the search bar on mobile platforms\n */\n\n const dark = useDarkMode();\n const isEnabled = dark?.isEnabled;\n\n if (mapboxToken != null) {\n mapboxgl.accessToken = mapboxToken;\n }\n\n if (styleType == \"macrostrat\") {\n style ??= isEnabled\n ? \"mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true\"\n : \"mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true\";\n } else {\n style ??= isEnabled\n ? \"mapbox://styles/mapbox/dark-v10\"\n : \"mapbox://styles/mapbox/light-v10\";\n }\n\n const [isOpen, setOpen] = useState(false);\n\n const [state, setState] = useStoredState(\"macrostrat:dev-map-page\", {\n showTileExtent: false,\n xRay: false,\n });\n const { showTileExtent, xRay } = state;\n\n const [actualStyle, setActualStyle] = useState(null);\n\n useEffect(() => {\n buildInspectorStyle(style, overlayStyle, {\n mapboxToken,\n inDarkMode: isEnabled,\n xRay,\n }).then(setActualStyle);\n }, [style, xRay, mapboxToken, isEnabled, overlayStyle]);\n\n const [inspectPosition, setInspectPosition] =\n useState<mapboxgl.LngLat | null>(null);\n\n const [data, setData] = useState(null);\n\n const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {\n setInspectPosition(position);\n }, []);\n\n let detailElement = null;\n if (inspectPosition != null) {\n detailElement = h(\n LocationPanel,\n {\n onClose() {\n setInspectPosition(null);\n },\n position: inspectPosition,\n },\n [\n h(TileInfo, {\n feature: data?.[0] ?? null,\n showExtent: showTileExtent,\n setShowExtent() {\n setState({ ...state, showTileExtent: !showTileExtent });\n },\n }),\n h(FeaturePanel, { features: data, focusedSource, focusedSourceTitle }),\n ]\n );\n }\n\n let tile = null;\n if (showTileExtent && data?.[0] != null) {\n let f = data[0];\n tile = { x: f._x, y: f._y, z: f._z };\n }\n\n return h(\n MapAreaContainer,\n {\n navbar: h(FloatingNavbar, {\n rightElement: h(MapLoadingButton, {\n large: true,\n active: isOpen,\n onClick: () => setOpen(!isOpen),\n style: {\n marginRight: \"-5px\",\n },\n }),\n headerElement,\n title,\n }),\n contextPanel: h(PanelCard, [\n controls,\n h(Switch, {\n checked: xRay,\n label: \"X-ray mode\",\n onChange() {\n setState({ ...state, xRay: !xRay });\n },\n }),\n ]),\n detailPanel: detailElement,\n contextPanelOpen: isOpen,\n fitViewport,\n },\n h(\n MapView,\n {\n style: actualStyle,\n transformRequest,\n mapPosition,\n projection: { name: \"globe\" },\n mapboxToken,\n bounds,\n },\n [\n h(FeatureSelectionHandler, {\n selectedLocation: inspectPosition,\n setFeatures: setData,\n }),\n h(MapMarker, {\n position: inspectPosition,\n setPosition: onSelectPosition,\n }),\n h(TileExtentLayer, { tile, color: isEnabled ? \"white\" : \"black\" }),\n children,\n ]\n )\n );\n}\n\nfunction MapInspector(props) {\n const { children, controls, ...rest } = props;\n /** Compatibility wrapper for MapInspectorV2 */\n // React warning about this legacy usage\n console.warn(\"MapInspector is deprecated. Use MapInspectorV2 instead\");\n\n return h(MapInspectorV2, {\n ...rest,\n controls: [children, controls],\n });\n}\n\n// Legacy export\nexport const DevMapPage = MapInspector;\n"],"names":[],"version":3,"file":"map-page.1e1970d8.js.map"}
|