@macrostrat/map-interface 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/index.js +4 -4
  3. package/dist/cjs/{map-interface.3934d6d6.js → map-interface.10d442f4.js} +2 -2
  4. package/dist/cjs/{map-interface.3934d6d6.js.map → map-interface.10d442f4.js.map} +1 -1
  5. package/dist/cjs/{map-interface.17e81e8a.js → map-interface.28d1a6b7.js} +10 -8
  6. package/dist/cjs/map-interface.28d1a6b7.js.map +1 -0
  7. package/dist/cjs/{map-interface.5cea0ff4.js → map-interface.3bc4f731.js} +3 -3
  8. package/dist/cjs/{map-interface.5cea0ff4.js.map → map-interface.3bc4f731.js.map} +1 -1
  9. package/dist/cjs/{map-interface.e7194f92.js → map-interface.7bdbe4b6.js} +59 -47
  10. package/dist/cjs/map-interface.7bdbe4b6.js.map +1 -0
  11. package/dist/cjs/{map-interface.5813e876.js → map-interface.cf6c9a68.js} +5 -5
  12. package/dist/cjs/{map-interface.5813e876.js.map → map-interface.cf6c9a68.js.map} +1 -1
  13. package/dist/cjs/{map-interface.1d19056e.js → map-interface.dcbd3874.js} +4 -2
  14. package/dist/cjs/map-interface.dcbd3874.js.map +1 -0
  15. package/dist/cjs/{map-interface.175c4635.js → map-interface.f8826069.js} +12 -17
  16. package/dist/cjs/map-interface.f8826069.js.map +1 -0
  17. package/dist/esm/index.d.ts +18 -29
  18. package/dist/esm/index.d.ts.map +1 -1
  19. package/dist/esm/index.js +4 -4
  20. package/dist/esm/map-interface.22ea3934.js +41 -0
  21. package/dist/esm/map-interface.22ea3934.js.map +1 -0
  22. package/dist/esm/{map-interface.e5349e97.js → map-interface.54ccd41f.js} +2 -2
  23. package/dist/esm/{map-interface.e5349e97.js.map → map-interface.54ccd41f.js.map} +1 -1
  24. package/dist/esm/{map-interface.3248abc7.js → map-interface.90d9023c.js} +3 -3
  25. package/dist/esm/{map-interface.3248abc7.js.map → map-interface.90d9023c.js.map} +1 -1
  26. package/dist/esm/{map-interface.9ce3d553.js → map-interface.ca1ee406.js} +61 -49
  27. package/dist/esm/map-interface.ca1ee406.js.map +1 -0
  28. package/dist/esm/{map-interface.e1493866.js → map-interface.e20a9bac.js} +4 -2
  29. package/dist/esm/map-interface.e20a9bac.js.map +1 -0
  30. package/dist/esm/{map-interface.00058d23.js → map-interface.ec2278ab.js} +10 -8
  31. package/dist/esm/map-interface.ec2278ab.js.map +1 -0
  32. package/dist/esm/{map-interface.45814073.js → map-interface.f7b8bdb7.js} +5 -5
  33. package/dist/esm/{map-interface.45814073.js.map → map-interface.f7b8bdb7.js.map} +1 -1
  34. package/dist/node/index.js +1 -1
  35. package/dist/node/index.js.map +1 -1
  36. package/dist/node/map-interface.0dc4417b.js +2 -0
  37. package/dist/node/map-interface.0dc4417b.js.map +1 -0
  38. package/dist/node/{map-interface.eb663cae.js → map-interface.33b7734a.js} +2 -2
  39. package/dist/node/map-interface.33b7734a.js.map +1 -0
  40. package/dist/node/map-interface.56b5b2ee.js +2 -0
  41. package/dist/node/map-interface.56b5b2ee.js.map +1 -0
  42. package/dist/node/{map-interface.cf540298.js → map-interface.6184dc0f.js} +2 -2
  43. package/dist/node/{map-interface.cf540298.js.map → map-interface.6184dc0f.js.map} +1 -1
  44. package/dist/node/map-interface.7295b0a2.js +2 -0
  45. package/dist/node/map-interface.7295b0a2.js.map +1 -0
  46. package/dist/node/map-interface.992dea73.js +2 -0
  47. package/dist/node/map-interface.992dea73.js.map +1 -0
  48. package/dist/node/{map-interface.d16a06b1.js → map-interface.f3e12e03.js} +2 -2
  49. package/dist/node/{map-interface.d16a06b1.js.map → map-interface.f3e12e03.js.map} +1 -1
  50. package/package.json +3 -3
  51. package/src/dev/map-page.ts +27 -20
  52. package/src/dev/tile-extent.ts +17 -18
  53. package/src/helpers.ts +4 -4
  54. package/src/location-panel/header.ts +2 -5
  55. package/src/map-view.ts +77 -52
  56. package/dist/cjs/map-interface.175c4635.js.map +0 -1
  57. package/dist/cjs/map-interface.17e81e8a.js.map +0 -1
  58. package/dist/cjs/map-interface.1d19056e.js.map +0 -1
  59. package/dist/cjs/map-interface.e7194f92.js.map +0 -1
  60. package/dist/esm/map-interface.00058d23.js.map +0 -1
  61. package/dist/esm/map-interface.9ce3d553.js.map +0 -1
  62. package/dist/esm/map-interface.e1493866.js.map +0 -1
  63. package/dist/esm/map-interface.f107347b.js +0 -46
  64. package/dist/esm/map-interface.f107347b.js.map +0 -1
  65. package/dist/node/map-interface.02dd6884.js +0 -2
  66. package/dist/node/map-interface.02dd6884.js.map +0 -1
  67. package/dist/node/map-interface.20c346ba.js +0 -2
  68. package/dist/node/map-interface.20c346ba.js.map +0 -1
  69. package/dist/node/map-interface.44d3f3bf.js +0 -2
  70. package/dist/node/map-interface.44d3f3bf.js.map +0 -1
  71. package/dist/node/map-interface.bc0fb98b.js +0 -2
  72. package/dist/node/map-interface.bc0fb98b.js.map +0 -1
  73. package/dist/node/map-interface.eb663cae.js.map +0 -1
@@ -1,2 +1,2 @@
1
- function $parcel$exportWildcard(e,r){return Object.keys(r).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})}),e}require("./map-interface.02dd6884.js"),require("./map-interface.44d3f3bf.js"),require("./map-interface.62b147ce.js"),require("./map-interface.2d12b35c.js");var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequirea149;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var r=$parcel$inits[e];delete $parcel$inits[e];var a={id:e,exports:{}};return $parcel$modules[e]=a,r.call(a.exports,a,a.exports),a.exports}var l=Error("Cannot find module '"+e+"'");throw l.code="MODULE_NOT_FOUND",l}).register=function(e,r){$parcel$inits[e]=r},$parcel$global.parcelRequirea149=parcelRequire);var parcelRegister=parcelRequire.register,$c9InG=parcelRequire("c9InG"),$2DICz=parcelRequire("2DICz"),$gnyJS=parcelRequire("gnyJS"),$2mAQJ=parcelRequire("2mAQJ");$parcel$exportWildcard(module.exports,$c9InG),$parcel$exportWildcard(module.exports,$2DICz),$parcel$exportWildcard(module.exports,$gnyJS),$parcel$exportWildcard(module.exports,$2mAQJ);
2
- //# sourceMappingURL=map-interface.d16a06b1.js.map
1
+ function $parcel$exportWildcard(e,r){return Object.keys(r).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})}),e}require("./map-interface.0dc4417b.js"),require("./map-interface.992dea73.js"),require("./map-interface.62b147ce.js"),require("./map-interface.2d12b35c.js");var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequirea149;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var r=$parcel$inits[e];delete $parcel$inits[e];var a={id:e,exports:{}};return $parcel$modules[e]=a,r.call(a.exports,a,a.exports),a.exports}var l=Error("Cannot find module '"+e+"'");throw l.code="MODULE_NOT_FOUND",l}).register=function(e,r){$parcel$inits[e]=r},$parcel$global.parcelRequirea149=parcelRequire);var parcelRegister=parcelRequire.register,$c9InG=parcelRequire("c9InG"),$2DICz=parcelRequire("2DICz"),$gnyJS=parcelRequire("gnyJS"),$2mAQJ=parcelRequire("2mAQJ");$parcel$exportWildcard(module.exports,$c9InG),$parcel$exportWildcard(module.exports,$2DICz),$parcel$exportWildcard(module.exports,$gnyJS),$parcel$exportWildcard(module.exports,$2mAQJ);
2
+ //# sourceMappingURL=map-interface.f3e12e03.js.map
@@ -1 +1 @@
1
- {"mappings":"A,S,uB,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,O,S,C,c,C,I,C,E,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,Q,gD,Q,gD,Q,gD,Q,gD,I,e,W,gB,C,E,c,C,E,c,e,iB,A,O,gB,A,C,c,S,C,E,G,K,gB,O,e,C,E,C,O,C,G,K,c,C,I,E,a,C,E,A,Q,a,C,E,C,I,E,C,G,E,Q,C,C,E,O,e,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,a,C,E,C,C,E,e,iB,C,e,I,e,c,Q,C,O,c,S,O,c,S,O,c,S,O,c,S,uB,O,O,C,Q,uB,O,O,C,Q,uB,O,O,C,Q,uB,O,O,C","sources":["<anon>","packages/map-interface/src/dev/index.ts"],"sourcesContent":["require(\"./map-interface.02dd6884.js\");\nrequire(\"./map-interface.44d3f3bf.js\");\nrequire(\"./map-interface.62b147ce.js\");\nrequire(\"./map-interface.2d12b35c.js\");\n\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $c9InG = parcelRequire(\"c9InG\");\n\nvar $2DICz = parcelRequire(\"2DICz\");\n\nvar $gnyJS = parcelRequire(\"gnyJS\");\n\nvar $2mAQJ = parcelRequire(\"2mAQJ\");\n$parcel$exportWildcard(module.exports, $c9InG);\n$parcel$exportWildcard(module.exports, $2DICz);\n$parcel$exportWildcard(module.exports, $gnyJS);\n$parcel$exportWildcard(module.exports, $2mAQJ);\n\n\n//# sourceMappingURL=map-interface.d16a06b1.js.map\n","export * from \"./map-page\";\nexport * from \"./tile-extent\";\nexport * from \"./vector-tile-features\";\nexport * from \"./xray\";\n"],"names":["$parcel$exportWildcard","dest","source","Object","keys","forEach","key","prototype","hasOwnProperty","call","defineProperty","enumerable","get","require","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","err","Error","code","register","parcelRegister","$c9InG","$2DICz","$gnyJS","$2mAQJ"],"version":3,"file":"map-interface.d16a06b1.js.map","sourceRoot":"../../../../"}
1
+ {"mappings":"A,S,uB,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,O,S,C,c,C,I,C,E,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,Q,gD,Q,gD,Q,gD,Q,gD,I,e,W,gB,C,E,c,C,E,c,e,iB,A,O,gB,A,C,c,S,C,E,G,K,gB,O,e,C,E,C,O,C,G,K,c,C,I,E,a,C,E,A,Q,a,C,E,C,I,E,C,G,E,Q,C,C,E,O,e,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,a,C,E,C,C,E,e,iB,C,e,I,e,c,Q,C,O,c,S,O,c,S,O,c,S,O,c,S,uB,O,O,C,Q,uB,O,O,C,Q,uB,O,O,C,Q,uB,O,O,C","sources":["<anon>","packages/map-interface/src/dev/index.ts"],"sourcesContent":["require(\"./map-interface.0dc4417b.js\");\nrequire(\"./map-interface.992dea73.js\");\nrequire(\"./map-interface.62b147ce.js\");\nrequire(\"./map-interface.2d12b35c.js\");\n\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $c9InG = parcelRequire(\"c9InG\");\n\nvar $2DICz = parcelRequire(\"2DICz\");\n\nvar $gnyJS = parcelRequire(\"gnyJS\");\n\nvar $2mAQJ = parcelRequire(\"2mAQJ\");\n$parcel$exportWildcard(module.exports, $c9InG);\n$parcel$exportWildcard(module.exports, $2DICz);\n$parcel$exportWildcard(module.exports, $gnyJS);\n$parcel$exportWildcard(module.exports, $2mAQJ);\n\n\n//# sourceMappingURL=map-interface.f3e12e03.js.map\n","export * from \"./map-page\";\nexport * from \"./tile-extent\";\nexport * from \"./vector-tile-features\";\nexport * from \"./xray\";\n"],"names":["$parcel$exportWildcard","dest","source","Object","keys","forEach","key","prototype","hasOwnProperty","call","defineProperty","enumerable","get","require","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","err","Error","code","register","parcelRegister","$c9InG","$2DICz","$gnyJS","$2mAQJ"],"version":3,"file":"map-interface.f3e12e03.js.map","sourceRoot":"../../../../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/map-interface",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Map interface for Macrostrat",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -11,8 +11,8 @@
11
11
  "@blueprintjs/core": "^5.0.0",
12
12
  "@macrostrat/color-utils": "^1.1.1",
13
13
  "@macrostrat/hyper": "^3.0.6",
14
- "@macrostrat/mapbox-react": "^2.6.1",
15
- "@macrostrat/mapbox-utils": "^1.5.1",
14
+ "@macrostrat/mapbox-react": "^2.6.2",
15
+ "@macrostrat/mapbox-utils": "^1.6.0",
16
16
  "@macrostrat/ui-components": "^4.3.0",
17
17
  "@mapbox/tilebelt": "^2.0.0",
18
18
  "classnames": "^2.5.1",
@@ -1,15 +1,16 @@
1
1
  // Import other components
2
2
  import { Switch } from "@blueprintjs/core";
3
3
  import hyper from "@macrostrat/hyper";
4
- import { Spacer, useDarkMode, useStoredState } from "@macrostrat/ui-components";
4
+ import { useDarkMode, useStoredState } from "@macrostrat/ui-components";
5
5
  import mapboxgl from "mapbox-gl";
6
+ import React from "react";
6
7
  import { useCallback, useState, useEffect } from "react";
7
8
  import { buildInspectorStyle } from "./xray";
8
9
  import { MapAreaContainer, PanelCard } from "../container";
9
10
  import { FloatingNavbar, MapLoadingButton } from "../context-panel";
10
11
  import { MapMarker, useBasicMapStyle } from "../helpers";
11
12
  import { LocationPanel } from "../location-panel";
12
- import { MapView } from "../map-view";
13
+ import { MapView, MapViewProps } from "../map-view";
13
14
  import styles from "./main.module.sass";
14
15
  import { TileExtentLayer } from "./tile-extent";
15
16
  import {
@@ -21,6 +22,25 @@ import { MapPosition } from "@macrostrat/mapbox-utils";
21
22
 
22
23
  export const h = hyper.styled(styles);
23
24
 
25
+ interface MapInspectorProps extends MapViewProps {
26
+ headerElement?: React.ReactNode;
27
+ transformRequest?: mapboxgl.RequestTransformFunction;
28
+ title?: string;
29
+ style?: mapboxgl.StyleSpecification | string;
30
+ controls?: React.ReactNode;
31
+ children?: React.ReactNode;
32
+ mapboxToken?: string;
33
+ overlayStyle?: mapboxgl.StyleSpecification | string;
34
+ focusedSource?: string;
35
+ focusedSourceTitle?: string;
36
+ projection?: string;
37
+ mapPosition?: MapPosition;
38
+ bounds?: [number, number, number, number];
39
+ fitViewport?: boolean;
40
+ styleType?: "standard" | "macrostrat";
41
+ enableTerrain?: boolean;
42
+ }
43
+
24
44
  export function MapInspectorV2({
25
45
  title = "Map inspector",
26
46
  headerElement = null,
@@ -36,23 +56,8 @@ export function MapInspectorV2({
36
56
  focusedSourceTitle = null,
37
57
  fitViewport = true,
38
58
  styleType = "macrostrat",
39
- }: {
40
- headerElement?: React.ReactNode;
41
- transformRequest?: mapboxgl.TransformRequestFunction;
42
- title?: string;
43
- style?: mapboxgl.Style | string;
44
- controls?: React.ReactNode;
45
- children?: React.ReactNode;
46
- mapboxToken?: string;
47
- overlayStyle?: mapboxgl.Style | string;
48
- focusedSource?: string;
49
- focusedSourceTitle?: string;
50
- projection?: string;
51
- mapPosition?: MapPosition;
52
- bounds?: [number, number, number, number];
53
- fitViewport?: boolean;
54
- styleType?: "standard" | "macrostrat";
55
- }) {
59
+ ...rest
60
+ }: MapInspectorProps) {
56
61
  /* We apply a custom style to the panel container when we are interacting
57
62
  with the search bar, so that we can block map interactions until search
58
63
  bar focus is lost.
@@ -67,7 +72,8 @@ export function MapInspectorV2({
67
72
  mapboxgl.accessToken = mapboxToken;
68
73
  }
69
74
 
70
- style ??= useBasicMapStyle({ styleType });
75
+ const basicStyle = useBasicMapStyle({ styleType });
76
+ style ??= basicStyle;
71
77
 
72
78
  const [isOpen, setOpen] = useState(false);
73
79
 
@@ -163,6 +169,7 @@ export function MapInspectorV2({
163
169
  projection: { name: "globe" },
164
170
  mapboxToken,
165
171
  bounds,
172
+ ...rest,
166
173
  },
167
174
  [
168
175
  h(FeatureSelectionHandler, {
@@ -1,6 +1,6 @@
1
- import { useMapConditionalStyle, useMapRef } from "@macrostrat/mapbox-react";
1
+ import { useMapStyleOperator } from "@macrostrat/mapbox-react";
2
2
  import { tileToGeoJSON } from "@mapbox/tilebelt";
3
- import { useCallback } from "react";
3
+ import { setGeoJSON } from "@macrostrat/mapbox-utils";
4
4
 
5
5
  type TileIndex = { x: number; y: number; z: number };
6
6
 
@@ -11,21 +11,25 @@ export function TileExtentLayer({
11
11
  tile: TileIndex | null;
12
12
  color?: string;
13
13
  }) {
14
- const styleCallback = useCallback(
15
- (map, val: TileIndex) => {
14
+ useMapStyleOperator(
15
+ (map) => {
16
16
  const style = map.getStyle();
17
17
  if (style.layers == null) return;
18
18
  style.layers = style.layers.filter((l) => l.id != "tile-extent");
19
- if (val == null) {
19
+ if (tile == null) {
20
20
  return map.setStyle(style);
21
21
  }
22
- const { x, y, z } = val;
22
+ const { x, y, z } = tile;
23
23
  const extent = tileToGeoJSON([x, y, z]);
24
- const source = {
25
- type: "geojson",
26
- data: extent,
27
- };
28
- const layer = {
24
+
25
+ setGeoJSON(map, "tile-extent", extent as any);
26
+
27
+ if (map.getLayer("tile-extent") != null) {
28
+ // If the layer already exists, we can just update it
29
+ map.removeLayer("tile-extent");
30
+ }
31
+
32
+ map.addLayer({
29
33
  id: "tile-extent",
30
34
  type: "line",
31
35
  source: "tile-extent",
@@ -33,14 +37,9 @@ export function TileExtentLayer({
33
37
  "line-color": color,
34
38
  "line-width": 2,
35
39
  },
36
- };
37
- style.sources["tile-extent"] = source;
38
- style.layers.push(layer);
39
- map.setStyle(style);
40
+ });
40
41
  },
41
- [color],
42
+ [color, tile],
42
43
  );
43
- const map = useMapRef();
44
- useMapConditionalStyle(map, tile, styleCallback);
45
44
  return null;
46
45
  }
package/src/helpers.ts CHANGED
@@ -136,18 +136,18 @@ export function MapLoadingReporter({
136
136
  const mapIsLoading = loadingRef.current;
137
137
  if (map == null) return;
138
138
 
139
- let didSendLoading = false;
139
+ //let didSendLoading = false;
140
140
 
141
141
  const loadingCallback = (evt) => {
142
142
  if (ignoredSources.includes(evt.sourceId) || mapIsLoading) return;
143
- if (didSendLoading) return;
143
+ //if (didSendLoading) return;
144
144
  onMapLoading?.(evt);
145
145
  dispatch({ type: "set-loading", payload: true });
146
146
  loadingRef.current = true;
147
- didSendLoading = true;
147
+ //didSendLoading = true;
148
148
  };
149
149
  const idleCallback = (evt) => {
150
- if (!mapIsLoading) return;
150
+ if (!map.loaded()) return;
151
151
  dispatch({ type: "set-loading", payload: false });
152
152
  loadingRef.current = false;
153
153
  onMapIdle?.(evt);
@@ -3,14 +3,11 @@ import hyper from "@macrostrat/hyper";
3
3
  import styles from "./main.module.sass";
4
4
  import { useToaster } from "@macrostrat/ui-components";
5
5
  import { LngLatCoords, Elevation } from "../location-info";
6
- import {
7
- LocationFocusButton,
8
- useFocusState,
9
- isCentered,
10
- } from "@macrostrat/mapbox-react";
6
+ import { LocationFocusButton, useFocusState } from "@macrostrat/mapbox-react";
11
7
  import classNames from "classnames";
12
8
  import type { ReactNode } from "react";
13
9
  import type { LngLatBounds, LngLatLike } from "mapbox-gl";
10
+ import { isCentered } from "@macrostrat/mapbox-utils";
14
11
 
15
12
  const h = hyper.styled(styles);
16
13
 
package/src/map-view.ts CHANGED
@@ -2,11 +2,11 @@ import hyper from "@macrostrat/hyper";
2
2
  import {
3
3
  useMapRef,
4
4
  useMapDispatch,
5
- useMapPosition,
6
5
  use3DTerrain,
7
6
  getTerrainLayerForStyle,
8
7
  useMapStatus,
9
8
  } from "@macrostrat/mapbox-react";
9
+ import React from "react";
10
10
  import {
11
11
  mapViewInfo,
12
12
  MapPosition,
@@ -55,9 +55,14 @@ export interface MapViewProps extends MapboxCoreOptions {
55
55
  standalone?: boolean;
56
56
  /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to
57
57
  * overlay on top of the main map style at runtime */
58
- overlayStyles?: Partial<mapboxgl.Style>[];
58
+ overlayStyles?: Partial<mapboxgl.StyleSpecification>[];
59
59
  /** A function to transform the map style before it is loaded */
60
- transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;
60
+ transformStyle?: (
61
+ style: mapboxgl.StyleSpecification,
62
+ ) => mapboxgl.StyleSpecification;
63
+ loadingIgnoredSources?: string[];
64
+ id?: string;
65
+ className?: string;
61
66
  }
62
67
 
63
68
  export interface MapboxOptionsExt extends MapboxCoreOptions {
@@ -71,7 +76,7 @@ function defaultInitializeMap(container, args: MapboxOptionsExt = {}) {
71
76
  container,
72
77
  maxZoom: 18,
73
78
  logoPosition: "bottom-left",
74
- trackResize: true,
79
+ trackResize: false,
75
80
  antialias: true,
76
81
  // This is a legacy option for Mapbox GL v2
77
82
  // @ts-ignore
@@ -121,12 +126,24 @@ export function MapView(props: MapViewProps) {
121
126
  standalone = false,
122
127
  overlayStyles,
123
128
  transformStyle,
129
+ trackResize = true,
130
+ loadingIgnoredSources = ["elevationMarker", "crossSectionEndpoints"],
131
+ id = "map",
132
+ className,
124
133
  ...rest
125
134
  } = props;
126
135
  if (enableTerrain) {
127
136
  terrainSourceID ??= "mapbox-3d-dem";
128
137
  }
129
138
 
139
+ useEffect(() => {
140
+ if (id != null) {
141
+ console.warn(
142
+ "Setting a specific element ID for the map is deprecated. Please use className instead.",
143
+ );
144
+ }
145
+ }, [id]);
146
+
130
147
  const _mapboxToken = mapboxToken ?? accessToken;
131
148
 
132
149
  if (_mapboxToken != null) {
@@ -139,26 +156,18 @@ export function MapView(props: MapViewProps) {
139
156
  const parentRef = useRef<HTMLDivElement>();
140
157
 
141
158
  const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);
142
- const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);
159
+
160
+ const estMapPosition: MapPosition | null =
161
+ mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);
162
+ const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);
163
+ const is3DAvailable = (mapUse3D ?? false) && enableTerrain;
143
164
 
144
165
  useEffect(() => {
145
166
  /** Manager to update map style */
146
167
  if (baseStyle == null) return;
147
168
  let map = mapRef.current;
148
169
 
149
- /** If we can, we try to update the map style with terrain information
150
- * immediately, before the style is loaded. This allows us to avoid a
151
- * flash of the map without terrain.
152
- *
153
- * To do this, we need to estimate the map position before load, which
154
- * doesn't always work.
155
- */
156
- // We either get the map position directly from the map or from props
157
- const estMapPosition: MapPosition | null =
158
- map == null ? mapPosition : getMapPosition(map);
159
- const { mapUse3D } = mapViewInfo(estMapPosition);
160
-
161
- let newStyle: mapboxgl.Style = baseStyle;
170
+ let newStyle: mapboxgl.StyleSpecification = baseStyle;
162
171
 
163
172
  const overlayStyles = props.overlayStyles ?? [];
164
173
 
@@ -166,7 +175,14 @@ export function MapView(props: MapViewProps) {
166
175
  newStyle = mergeStyles(newStyle, ...overlayStyles);
167
176
  }
168
177
 
169
- if (mapUse3D) {
178
+ /** If we can, we try to update the map style with terrain information
179
+ * immediately, before the style is loaded. This allows us to avoid a
180
+ * flash of the map without terrain.
181
+ *
182
+ * To do this, we need to estimate the map position before load, which
183
+ * doesn't always work.
184
+ */
185
+ if (is3DAvailable) {
170
186
  // We can update the style with terrain layers immediately
171
187
  const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);
172
188
  newStyle = mergeStyles(newStyle, terrainStyle);
@@ -177,11 +193,9 @@ export function MapView(props: MapViewProps) {
177
193
  }
178
194
 
179
195
  if (map != null) {
180
- console.log("Setting style", newStyle);
181
196
  dispatch({ type: "set-style-loaded", payload: false });
182
197
  map.setStyle(newStyle);
183
198
  } else {
184
- console.log("Initializing map", newStyle);
185
199
  const map = initializeMap(ref.current, {
186
200
  style: newStyle,
187
201
  projection,
@@ -195,26 +209,9 @@ export function MapView(props: MapViewProps) {
195
209
  }
196
210
  }, [baseStyle, overlayStyles, transformStyle]);
197
211
 
198
- /** Check back every 0.1 seconds to see if the map has loaded.
199
- * We do it this way because mapboxgl loading events are unreliable */
200
- useEffect(() => {
201
- if (isStyleLoaded) return;
202
- const interval = setInterval(() => {
203
- const map = mapRef.current;
204
- if (map == null) return;
205
- if (map.isStyleLoaded()) {
206
- // Wait a tick before setting the style loaded state
207
- dispatch({ type: "set-style-loaded", payload: true });
208
- onStyleLoaded?.(map);
209
- clearInterval(interval);
210
- }
211
- }, 50);
212
- return () => clearInterval(interval);
213
- }, [isStyleLoaded]);
214
-
215
212
  useAsyncEffect(async () => {
216
213
  /** Manager to update map style */
217
- let newStyle: mapboxgl.Style;
214
+ let newStyle: mapboxgl.StyleSpecification;
218
215
  if (typeof style === "string") {
219
216
  newStyle = await getMapboxStyle(style, {
220
217
  access_token: mapboxgl.accessToken,
@@ -225,45 +222,73 @@ export function MapView(props: MapViewProps) {
225
222
  setBaseStyle(newStyle);
226
223
  }, [style]);
227
224
 
228
- const _computedMapPosition = useMapPosition();
229
- const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);
230
-
231
225
  // Get map projection
232
226
  const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
233
227
 
234
- const className = classNames(
228
+ const mapClassName = classNames(
235
229
  {
236
230
  "is-rotated": mapIsRotated ?? false,
237
- "is-3d-available": mapUse3D ?? false,
231
+ "is-3d-available": is3DAvailable,
238
232
  },
239
233
  `${_projection}-projection`,
240
234
  );
241
235
 
242
- const parentClassName = classNames({
243
- standalone,
244
- });
236
+ const parentClassName = classNames(
237
+ {
238
+ standalone,
239
+ },
240
+ className,
241
+ );
245
242
 
246
243
  return h(
247
244
  "div.map-view-container.main-view",
248
245
  { ref: parentRef, className: parentClassName },
249
246
  [
250
- h("div.mapbox-map#map", { ref, className }),
247
+ h("div.mapbox-map.map-view", { ref, className: mapClassName, id }),
251
248
  h(MapLoadingReporter, {
252
- ignoredSources: ["elevationMarker", "crossSectionEndpoints"],
249
+ ignoredSources: loadingIgnoredSources,
253
250
  }),
251
+ h(StyleLoadedReporter, { onStyleLoaded }),
254
252
  h(MapMovedReporter, { onMapMoved }),
255
- h(MapResizeManager, { containerRef: ref }),
253
+ // Subsitute for trackResize: true that allows map resizing to
254
+ // be tied to a specific ref component
255
+ h.if(trackResize)(MapResizeManager, { containerRef: ref }),
256
256
  h(MapPaddingManager, {
257
257
  containerRef: ref,
258
258
  parentRef,
259
259
  infoMarkerPosition,
260
260
  }),
261
- h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),
261
+ h(MapTerrainManager, { mapUse3D: is3DAvailable, terrainSourceID, style }),
262
262
  children,
263
263
  ],
264
264
  );
265
265
  }
266
266
 
267
+ function StyleLoadedReporter({ onStyleLoaded = null }) {
268
+ /** Check back every 0.1 seconds to see if the map has loaded.
269
+ * We do it this way because mapboxgl loading events are unreliable */
270
+ const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);
271
+ const mapRef = useMapRef();
272
+ const dispatch = useMapDispatch();
273
+
274
+ useEffect(() => {
275
+ if (isStyleLoaded) return;
276
+ const interval = setInterval(() => {
277
+ const map = mapRef.current;
278
+ if (map == null) return;
279
+ if (map.isStyleLoaded()) {
280
+ // Wait a tick before setting the style loaded state
281
+ dispatch({ type: "set-style-loaded", payload: true });
282
+ onStyleLoaded?.(map);
283
+ clearInterval(interval);
284
+ }
285
+ }, 50);
286
+ return () => clearInterval(interval);
287
+ }, [isStyleLoaded]);
288
+
289
+ return null;
290
+ }
291
+
267
292
  export function MapTerrainManager({
268
293
  mapUse3D,
269
294
  terrainSourceID,
@@ -271,7 +296,7 @@ export function MapTerrainManager({
271
296
  }: {
272
297
  mapUse3D?: boolean;
273
298
  terrainSourceID?: string;
274
- style?: mapboxgl.Style | string;
299
+ style?: mapboxgl.StyleSpecification | string;
275
300
  }) {
276
301
  use3DTerrain(mapUse3D, terrainSourceID);
277
302
 
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;AAMO,SAAS,0CAAgB,QAC9B,IAAI,SACJ,QAAQ,OAIT;IACC,MAAM,gBAAgB,CAAA,GAAA,wBAAU,EAC9B,CAAC,KAAK;QACJ,MAAM,QAAQ,IAAI,QAAQ;QAC1B,IAAI,MAAM,MAAM,IAAI,MAAM;QAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAM,EAAE,EAAE,IAAI;QAClD,IAAI,OAAO,MACT,OAAO,IAAI,QAAQ,CAAC;QAEtB,MAAM,KAAE,CAAC,KAAE,CAAC,KAAE,CAAC,EAAE,GAAG;QACpB,MAAM,SAAS,CAAA,GAAA,mCAAY,EAAE;YAAC;YAAG;YAAG;SAAE;QACtC,MAAM,SAAS;YACb,MAAM;YACN,MAAM;QACR;QACA,MAAM,QAAQ;YACZ,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,OAAO;gBACL,cAAc;gBACd,cAAc;YAChB;QACF;QACA,MAAM,OAAO,CAAC,cAAc,GAAG;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC;QAClB,IAAI,QAAQ,CAAC;IACf,GACA;QAAC;KAAM;IAET,MAAM,MAAM,CAAA,GAAA,sCAAQ;IACpB,CAAA,GAAA,mDAAqB,EAAE,KAAK,MAAM;IAClC,OAAO;AACT","sources":["packages/map-interface/src/dev/tile-extent.ts"],"sourcesContent":["import { useMapConditionalStyle, useMapRef } from \"@macrostrat/mapbox-react\";\nimport { tileToGeoJSON } from \"@mapbox/tilebelt\";\nimport { useCallback } from \"react\";\n\ntype TileIndex = { x: number; y: number; z: number };\n\nexport function TileExtentLayer({\n tile,\n color = \"red\",\n}: {\n tile: TileIndex | null;\n color?: string;\n}) {\n const styleCallback = useCallback(\n (map, val: TileIndex) => {\n const style = map.getStyle();\n if (style.layers == null) return;\n style.layers = style.layers.filter((l) => l.id != \"tile-extent\");\n if (val == null) {\n return map.setStyle(style);\n }\n const { x, y, z } = val;\n const extent = tileToGeoJSON([x, y, z]);\n const source = {\n type: \"geojson\",\n data: extent,\n };\n const layer = {\n id: \"tile-extent\",\n type: \"line\",\n source: \"tile-extent\",\n paint: {\n \"line-color\": color,\n \"line-width\": 2,\n },\n };\n style.sources[\"tile-extent\"] = source;\n style.layers.push(layer);\n map.setStyle(style);\n },\n [color],\n );\n const map = useMapRef();\n useMapConditionalStyle(map, tile, styleCallback);\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.175c4635.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAA0B;;;;;;;;;;;;;;;AAqBnB,MAAM,4CAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAE5B,SAAS,0CAAe,SAC7B,QAAQ,gCACR,gBAAgB,wBAChB,mBAAmB,mBACnB,cAAc,mBACd,cAAc,oBACd,eAAe,gBACf,WAAW,gBACX,WAAW,aACX,KAAK,UACL,SAAS,qBACT,gBAAgB,0BAChB,qBAAqB,mBACrB,cAAc,iBACd,YAAY,cAiBb;IACC;;;;;EAKA,GAEA,MAAM,OAAO,CAAA,GAAA,yCAAU;IACvB,MAAM,YAAY,MAAM;IAExB,IAAI,eAAe,MACjB,CAAA,GAAA,yCAAO,EAAE,WAAW,GAAG;IAGzB,UAAU,CAAA,GAAA,0CAAe,EAAE;mBAAE;IAAU;IAEvC,MAAM,CAAC,QAAQ,QAAQ,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEnC,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,4CAAa,EAAE,2BAA2B;QAClE,gBAAgB;QAChB,MAAM;IACR;IACA,MAAM,kBAAE,cAAc,QAAE,IAAI,EAAE,GAAG;IAEjC,MAAM,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAE;IAE/C,CAAA,GAAA,sBAAQ,EAAE;QACR,CAAA,GAAA,6CAAkB,EAAE,OAAO,cAAc;yBACvC;YACA,YAAY;kBACZ;QACF,GAAG,IAAI,CAAC;IACV,GAAG;QAAC;QAAO;QAAM;QAAa;QAAW;K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AAa;QACb,kBAAkB;qBAClB;IACF,GACA,0CACE,CAAA,GAAA,iCAAM,GACN;QACE,OAAO;0BACP;qBACA;QACA,YAAY;YAAE,MAAM;QAAQ;qBAC5B;gBACA;IACF,GACA;QACE,0CAAE,CAAA,GAAA,iDAAsB,GAAG;YACzB,kBAAkB;YAClB,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,mCAAQ,GAAG;YACX,UAAU;YACV,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,yCAAc,GAAG;kBAAE;YAAM,OAAO,YAAY,UAAU;QAAQ;QAChE;KACD;AAGP;AAEA,SAAS,mCAAa,KAAK;IACzB,MAAM,YAAE,QAAQ,YAAE,QAAQ,EAAE,GAAG,MAAM,GAAG;IACxC,6CAA6C,GAC7C,wCAAwC;IACxC,QAAQ,IAAI,CAAC;IAEb,OAAO,0CAAE,2CAAgB;QACvB,GAAG,IAAI;QACP,UAAU;YAAC;YAAU;SAAS;IAChC;AACF;AAGO,MAAM,4CAAa","sources":["packages/map-interface/src/dev/map-page.ts"],"sourcesContent":["// Import other components\nimport { Switch } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport { Spacer, useDarkMode, useStoredState } from \"@macrostrat/ui-components\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useCallback, useState, useEffect } from \"react\";\nimport { buildInspectorStyle } from \"./xray\";\nimport { MapAreaContainer, PanelCard } from \"../container\";\nimport { FloatingNavbar, MapLoadingButton } from \"../context-panel\";\nimport { MapMarker, useBasicMapStyle } from \"../helpers\";\nimport { LocationPanel } from \"../location-panel\";\nimport { MapView } from \"../map-view\";\nimport styles from \"./main.module.sass\";\nimport { TileExtentLayer } from \"./tile-extent\";\nimport {\n FeaturePanel,\n FeatureSelectionHandler,\n TileInfo,\n} from \"./vector-tile-features\";\nimport { MapPosition } from \"@macrostrat/mapbox-utils\";\n\nexport const h = hyper.styled(styles);\n\nexport function MapInspectorV2({\n title = \"Map inspector\",\n headerElement = null,\n transformRequest = null,\n mapPosition = null,\n mapboxToken = null,\n overlayStyle = null,\n controls = null,\n children = null,\n style,\n bounds = null,\n focusedSource = null,\n focusedSourceTitle = null,\n fitViewport = true,\n styleType = \"macrostrat\",\n}: {\n headerElement?: React.ReactNode;\n transformRequest?: mapboxgl.TransformRequestFunction;\n title?: string;\n style?: mapboxgl.Style | string;\n controls?: React.ReactNode;\n children?: React.ReactNode;\n mapboxToken?: string;\n overlayStyle?: mapboxgl.Style | string;\n focusedSource?: string;\n focusedSourceTitle?: string;\n projection?: string;\n mapPosition?: MapPosition;\n bounds?: [number, number, number, number];\n fitViewport?: boolean;\n styleType?: \"standard\" | \"macrostrat\";\n}) {\n /* We apply a custom style to the panel container when we are interacting\n with the search bar, so that we can block map interactions until search\n bar focus is lost.\n We also apply a custom style when the infodrawer is open so we can hide\n the search bar on mobile platforms\n */\n\n const dark = useDarkMode();\n const isEnabled = dark?.isEnabled;\n\n if (mapboxToken != null) {\n mapboxgl.accessToken = mapboxToken;\n }\n\n style ??= useBasicMapStyle({ styleType });\n\n const [isOpen, setOpen] = useState(false);\n\n const [state, setState] = useStoredState(\"macrostrat:dev-map-page\", {\n showTileExtent: false,\n xRay: false,\n });\n const { showTileExtent, xRay } = state;\n\n const [actualStyle, setActualStyle] = useState(null);\n\n useEffect(() => {\n buildInspectorStyle(style, overlayStyle, {\n mapboxToken,\n inDarkMode: isEnabled,\n xRay,\n }).then(setActualStyle);\n }, [style, xRay, mapboxToken, isEnabled, overlayStyle]);\n\n const [inspectPosition, setInspectPosition] =\n useState<mapboxgl.LngLat | null>(null);\n\n const [data, setData] = useState(null);\n\n const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {\n setInspectPosition(position);\n }, []);\n\n let detailElement = null;\n if (inspectPosition != null) {\n detailElement = h(\n LocationPanel,\n {\n onClose() {\n setInspectPosition(null);\n },\n position: inspectPosition,\n },\n [\n h(TileInfo, {\n feature: data?.[0] ?? null,\n showExtent: showTileExtent,\n setShowExtent() {\n setState({ ...state, showTileExtent: !showTileExtent });\n },\n }),\n h(FeaturePanel, { features: data, focusedSource, focusedSourceTitle }),\n ],\n );\n }\n\n let tile = null;\n if (showTileExtent && data?.[0] != null) {\n let f = data[0];\n tile = { x: f._x, y: f._y, z: f._z };\n }\n\n return h(\n MapAreaContainer,\n {\n navbar: h(FloatingNavbar, {\n rightElement: h(MapLoadingButton, {\n large: true,\n active: isOpen,\n onClick: () => setOpen(!isOpen),\n style: {\n marginRight: \"-5px\",\n },\n }),\n headerElement,\n title,\n }),\n contextPanel: h(PanelCard, [\n controls,\n h(Switch, {\n checked: xRay,\n label: \"X-ray mode\",\n onChange() {\n setState({ ...state, xRay: !xRay });\n },\n }),\n ]),\n detailPanel: detailElement,\n contextPanelOpen: isOpen,\n fitViewport,\n },\n h(\n MapView,\n {\n style: actualStyle,\n transformRequest,\n mapPosition,\n projection: { name: \"globe\" },\n mapboxToken,\n bounds,\n },\n [\n h(FeatureSelectionHandler, {\n selectedLocation: inspectPosition,\n setFeatures: setData,\n }),\n h(MapMarker, {\n position: inspectPosition,\n setPosition: onSelectPosition,\n }),\n h(TileExtentLayer, { tile, color: isEnabled ? \"white\" : \"black\" }),\n children,\n ],\n ),\n );\n}\n\nfunction MapInspector(props) {\n const { children, controls, ...rest } = props;\n /** Compatibility wrapper for MapInspectorV2 */\n // React warning about this legacy usage\n console.warn(\"MapInspector is deprecated. Use MapInspectorV2 instead\");\n\n return h(MapInspectorV2, {\n ...rest,\n controls: [children, controls],\n });\n}\n\n// Legacy export\nexport const DevMapPage = MapInspector;\n"],"names":[],"version":3,"file":"map-interface.17e81e8a.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAE5B,SAAS,qCAAe,YAAE,QAAQ,UAAE,MAAM,gBAAE,eAAe,OAAO;IAChE,MAAM,aAAa,CAAA,GAAA,0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AA,GAAA,2CAAS,EAAE,WAAW;YAAE,gBAAgB;QAAY;IACjE,GACA;QACE;QACA;QACA,wBAAE;QACF,wBAAE,EAAE,CAAC,YAAY,MAAM,CAAA,GAAA,sCAAW,GAAG;sBACnC;kBACA;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,aAAa,MAAM,CAAA,GAAA,mCAAQ,GAAG;uBACjC;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,WAAW,MAAM,CAAA,GAAA,6BAAK,GAAG;YAC5B,SAAS;YACT,MAAM;YACN,SAAS;QACX;KACD;AAEL","sources":["packages/map-interface/src/location-panel/header.ts"],"sourcesContent":["import { Icon, Button } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useToaster } from \"@macrostrat/ui-components\";\nimport { LngLatCoords, Elevation } from \"../location-info\";\nimport {\n LocationFocusButton,\n useFocusState,\n isCentered,\n} from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\nimport type { ReactNode } from \"react\";\nimport type { LngLatBounds, LngLatLike } from \"mapbox-gl\";\n\nconst h = hyper.styled(styles);\n\nfunction PositionButton({ position, bounds, showCopyLink = false }) {\n const focusState = useFocusState(position);\n\n const copyLinkIsVisible = isCentered(focusState) && showCopyLink;\n\n return h(\"div.position-controls\", [\n h(LocationFocusButton, { location: position, bounds, focusState }, []),\n h.if(copyLinkIsVisible && position != null)(CopyLinkButton, {\n itemName: \"position\",\n }),\n ]);\n}\n\nfunction CopyLinkButton({ itemName, children, onClick, ...rest }) {\n const toaster = useToaster();\n\n let message = `Copied link`;\n if (itemName != null) {\n message += ` to ${itemName}`;\n }\n message += \"!\";\n\n return h(\n Button,\n {\n className: \"copy-link-button\",\n rightIcon: h(Icon, { icon: \"link\", size: 12 }),\n minimal: true,\n small: true,\n onClick() {\n navigator.clipboard.writeText(window.location.href).then(\n () => {\n toaster?.show({\n message,\n intent: \"success\",\n icon: \"clipboard\",\n timeout: 1000,\n });\n onClick?.();\n },\n () => {\n toaster?.show({\n message: \"Failed to copy link\",\n intent: \"danger\",\n icon: \"error\",\n timeout: 1000,\n });\n },\n );\n },\n ...rest,\n },\n children ?? \"Copy link\",\n );\n}\n\nexport interface InfoDrawerHeaderProps {\n onClose?: () => void;\n position?: LngLatLike;\n zoom?: number;\n elevation?: number;\n showCopyPositionButton?: boolean;\n bounds?: LngLatBounds;\n fixedHeight?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport function InfoDrawerHeader(props: InfoDrawerHeaderProps) {\n const {\n onClose,\n position,\n bounds,\n zoom = 7,\n elevation,\n showCopyPositionButton,\n fixedHeight = false,\n children,\n className,\n } = props;\n\n let leftButton = null;\n if (bounds != null || position != null) {\n leftButton = h(PositionButton, {\n position,\n bounds,\n showCopyLink: showCopyPositionButton,\n });\n }\n\n return h(\n \"header.location-panel-header\",\n {\n className: classNames(className, { \"fixed-height\": fixedHeight }),\n },\n [\n leftButton,\n children,\n h(\"div.spacer\"),\n h.if(position != null)(LngLatCoords, {\n position,\n zoom,\n className: \"infodrawer-header-item\",\n }),\n h.if(elevation != null)(Elevation, {\n elevation,\n className: \"infodrawer-header-item\",\n }),\n h.if(onClose != null)(Button, {\n minimal: true,\n icon: \"cross\",\n onClick: onClose,\n }),\n ],\n );\n}\n"],"names":[],"version":3,"file":"map-interface.1d19056e.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,0BAAI,CAAA,GAAA,gDAAI,EAAE,MAAM,CAAC,CAAA,GAAA,mDAAK;AAmC5B,SAAS,2CAAqB,SAAS,EAAE,OAAyB,CAAC,CAAC;IAClE,MAAM,eAAE,WAAW,EAAE,GAAG,MAAM,GAAG;IAEjC,MAAM,MAAM,IAAI,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;mBAC3B;QACA,SAAS;QACT,cAAc;QACd,aAAa;QACb,WAAW;QACX,2CAA2C;QAC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,IAAI,OAAO,UAAU,UACnB,WAAW,MAAM,CAAA,GAAA,2CAAa,EAAE,OAAO;YACrC,cAAc,CAAA,GAAA,yCAAO,EAAE,WAAW;QACpC;aAEA,WAAW;QAEb,aAAa;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,MAAM,kBAAkB,CAAA,GAAA,2CAAS,EAAE;oBACjC;IACF;IAEA,OAAO,wBACL,oCACA;QAAE,KAAK;QAAW,WAAW;IAAgB,GAC7C;QACE,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;YACnB,cAAc;uBACd;gCACA;QACF;QACA,wBAAE,2CAAmB;sBAAE;6BAAU;mBAAiB;QAAM;QACxD;KACD;AAEL;AAEO,SAAS,0CAAkB,YAChC,QAAQ,mBACR,eAAe,SACf,KAAK,EAKN;IACC,CAAA,GAAA,yCAAW,EAAE,UAAU;IAEvB,OAAO;AACT","sources":["packages/map-interface/src/map-view.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt,\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.Style>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n // We either get the map position directly from the map or from props\n const estMapPosition: MapPosition | null =\n map == null ? mapPosition : getMapPosition(map);\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n let newStyle: mapboxgl.Style = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n if (mapUse3D) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n console.log(\"Setting style\", newStyle);\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, transformStyle]);\n\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.Style;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`,\n );\n\n const parentClassName = classNames({\n standalone,\n });\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.Style | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.e7194f92.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0BAA0B;;;;;;;;;;;;;;;AAqBnB,MAAM,4CAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,wEAAK;AAE5B,SAAS,0CAAe,SAC7B,QAAQ,gCACR,gBAAgB,wBAChB,mBAAmB,mBACnB,cAAc,mBACd,cAAc,oBACd,eAAe,gBACf,WAAW,gBACX,WAAW,aACX,KAAK,UACL,SAAS,qBACT,gBAAgB,0BAChB,qBAAqB,mBACrB,cAAc,iBACd,YAAY,cAiBb;IACC;;;;;EAKA,GAEA,MAAM,OAAO,CAAA,GAAA,kBAAU;IACvB,MAAM,YAAY,MAAM;IAExB,IAAI,eAAe,MACjB,CAAA,GAAA,eAAO,EAAE,WAAW,GAAG;IAGzB,UAAU,CAAA,GAAA,yCAAe,EAAE;mBAAE;IAAU;IAEvC,MAAM,CAAC,QAAQ,QAAQ,GAAG,CAAA,GAAA,eAAO,EAAE;IAEnC,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAa,EAAE,2BAA2B;QAClE,gBAAgB;QAChB,MAAM;IACR;IACA,MAAM,kBAAE,cAAc,QAA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B,OAAO;oBACL,aAAa;gBACf;YACF;2BACA;mBACA;QACF;QACA,cAAc,0CAAE,CAAA,GAAA,yCAAQ,GAAG;YACzB;YACA,0CAAE,CAAA,GAAA,aAAK,GAAG;gBACR,SAAS;gBACT,OAAO;gBACP;oBACE,SAAS;wBAAE,GAAG,KAAK;wBAAE,MAAM,CAAC;oBAAK;gBACnC;YACF;SACD;QACD,aAAa;QACb,kBAAkB;qBAClB;IACF,GACA,0CACE,CAAA,GAAA,yCAAM,GACN;QACE,OAAO;0BACP;qBACA;QACA,YAAY;YAAE,MAAM;QAAQ;qBAC5B;gBACA;IACF,GACA;QACE,0CAAE,CAAA,GAAA,yCAAsB,GAAG;YACzB,kBAAkB;YAClB,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,yCAAQ,GAAG;YACX,UAAU;YACV,aAAa;QACf;QACA,0CAAE,CAAA,GAAA,yCAAc,GAAG;kBAAE;YAAM,OAAO,YAAY,UAAU;QAAQ;QAChE;KACD;AAGP;AAEA,SAAS,mCAAa,KAAK;IACzB,MAAM,YAAE,QAAQ,YAAE,QAAQ,EAAE,GAAG,MAAM,GAAG;IACxC,6CAA6C,GAC7C,wCAAwC;IACxC,QAAQ,IAAI,CAAC;IAEb,OAAO,0CAAE,2CAAgB;QACvB,GAAG,IAAI;QACP,UAAU;YAAC;YAAU;SAAS;IAChC;AACF;AAGO,MAAM,4CAAa","sources":["packages/map-interface/src/dev/map-page.ts"],"sourcesContent":["// Import other components\nimport { Switch } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport { Spacer, useDarkMode, useStoredState } from \"@macrostrat/ui-components\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useCallback, useState, useEffect } from \"react\";\nimport { buildInspectorStyle } from \"./xray\";\nimport { MapAreaContainer, PanelCard } from \"../container\";\nimport { FloatingNavbar, MapLoadingButton } from \"../context-panel\";\nimport { MapMarker, useBasicMapStyle } from \"../helpers\";\nimport { LocationPanel } from \"../location-panel\";\nimport { MapView } from \"../map-view\";\nimport styles from \"./main.module.sass\";\nimport { TileExtentLayer } from \"./tile-extent\";\nimport {\n FeaturePanel,\n FeatureSelectionHandler,\n TileInfo,\n} from \"./vector-tile-features\";\nimport { MapPosition } from \"@macrostrat/mapbox-utils\";\n\nexport const h = hyper.styled(styles);\n\nexport function MapInspectorV2({\n title = \"Map inspector\",\n headerElement = null,\n transformRequest = null,\n mapPosition = null,\n mapboxToken = null,\n overlayStyle = null,\n controls = null,\n children = null,\n style,\n bounds = null,\n focusedSource = null,\n focusedSourceTitle = null,\n fitViewport = true,\n styleType = \"macrostrat\",\n}: {\n headerElement?: React.ReactNode;\n transformRequest?: mapboxgl.TransformRequestFunction;\n title?: string;\n style?: mapboxgl.Style | string;\n controls?: React.ReactNode;\n children?: React.ReactNode;\n mapboxToken?: string;\n overlayStyle?: mapboxgl.Style | string;\n focusedSource?: string;\n focusedSourceTitle?: string;\n projection?: string;\n mapPosition?: MapPosition;\n bounds?: [number, number, number, number];\n fitViewport?: boolean;\n styleType?: \"standard\" | \"macrostrat\";\n}) {\n /* We apply a custom style to the panel container when we are interacting\n with the search bar, so that we can block map interactions until search\n bar focus is lost.\n We also apply a custom style when the infodrawer is open so we can hide\n the search bar on mobile platforms\n */\n\n const dark = useDarkMode();\n const isEnabled = dark?.isEnabled;\n\n if (mapboxToken != null) {\n mapboxgl.accessToken = mapboxToken;\n }\n\n style ??= useBasicMapStyle({ styleType });\n\n const [isOpen, setOpen] = useState(false);\n\n const [state, setState] = useStoredState(\"macrostrat:dev-map-page\", {\n showTileExtent: false,\n xRay: false,\n });\n const { showTileExtent, xRay } = state;\n\n const [actualStyle, setActualStyle] = useState(null);\n\n useEffect(() => {\n buildInspectorStyle(style, overlayStyle, {\n mapboxToken,\n inDarkMode: isEnabled,\n xRay,\n }).then(setActualStyle);\n }, [style, xRay, mapboxToken, isEnabled, overlayStyle]);\n\n const [inspectPosition, setInspectPosition] =\n useState<mapboxgl.LngLat | null>(null);\n\n const [data, setData] = useState(null);\n\n const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {\n setInspectPosition(position);\n }, []);\n\n let detailElement = null;\n if (inspectPosition != null) {\n detailElement = h(\n LocationPanel,\n {\n onClose() {\n setInspectPosition(null);\n },\n position: inspectPosition,\n },\n [\n h(TileInfo, {\n feature: data?.[0] ?? null,\n showExtent: showTileExtent,\n setShowExtent() {\n setState({ ...state, showTileExtent: !showTileExtent });\n },\n }),\n h(FeaturePanel, { features: data, focusedSource, focusedSourceTitle }),\n ],\n );\n }\n\n let tile = null;\n if (showTileExtent && data?.[0] != null) {\n let f = data[0];\n tile = { x: f._x, y: f._y, z: f._z };\n }\n\n return h(\n MapAreaContainer,\n {\n navbar: h(FloatingNavbar, {\n rightElement: h(MapLoadingButton, {\n large: true,\n active: isOpen,\n onClick: () => setOpen(!isOpen),\n style: {\n marginRight: \"-5px\",\n },\n }),\n headerElement,\n title,\n }),\n contextPanel: h(PanelCard, [\n controls,\n h(Switch, {\n checked: xRay,\n label: \"X-ray mode\",\n onChange() {\n setState({ ...state, xRay: !xRay });\n },\n }),\n ]),\n detailPanel: detailElement,\n contextPanelOpen: isOpen,\n fitViewport,\n },\n h(\n MapView,\n {\n style: actualStyle,\n transformRequest,\n mapPosition,\n projection: { name: \"globe\" },\n mapboxToken,\n bounds,\n },\n [\n h(FeatureSelectionHandler, {\n selectedLocation: inspectPosition,\n setFeatures: setData,\n }),\n h(MapMarker, {\n position: inspectPosition,\n setPosition: onSelectPosition,\n }),\n h(TileExtentLayer, { tile, color: isEnabled ? \"white\" : \"black\" }),\n children,\n ],\n ),\n );\n}\n\nfunction MapInspector(props) {\n const { children, controls, ...rest } = props;\n /** Compatibility wrapper for MapInspectorV2 */\n // React warning about this legacy usage\n console.warn(\"MapInspector is deprecated. Use MapInspectorV2 instead\");\n\n return h(MapInspectorV2, {\n ...rest,\n controls: [children, controls],\n });\n}\n\n// Legacy export\nexport const DevMapPage = MapInspector;\n"],"names":[],"version":3,"file":"map-interface.00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B,GAAG;YACnB,cAAc;uBACd;gCACA;QACF;QACA,wBAAE,2CAAmB;sBAAE;6BAAU;mBAAiB;QAAM;QACxD;KACD;AAEL;AAEO,SAAS,0CAAkB,YAChC,QAAQ,mBACR,eAAe,SACf,KAAK,EAKN;IACC,CAAA,GAAA,mBAAW,EAAE,UAAU;IAEvB,OAAO;AACT","sources":["packages/map-interface/src/map-view.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n useMapPosition,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt,\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.Style>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (style: mapboxgl.Style) => mapboxgl.Style;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: true,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n // We either get the map position directly from the map or from props\n const estMapPosition: MapPosition | null =\n map == null ? mapPosition : getMapPosition(map);\n const { mapUse3D } = mapViewInfo(estMapPosition);\n\n let newStyle: mapboxgl.Style = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n if (mapUse3D) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n console.log(\"Setting style\", newStyle);\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n console.log(\"Initializing map\", newStyle);\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, transformStyle]);\n\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.Style;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n const _computedMapPosition = useMapPosition();\n const { mapUse3D, mapIsRotated } = mapViewInfo(_computedMapPosition);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const className = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": mapUse3D ?? false,\n },\n `${_projection}-projection`,\n );\n\n const parentClassName = classNames({\n standalone,\n });\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map#map\", { ref, className }),\n h(MapLoadingReporter, {\n ignoredSources: [\"elevationMarker\", \"crossSectionEndpoints\"],\n }),\n h(MapMovedReporter, { onMapMoved }),\n h(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.Style | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":[],"version":3,"file":"map-interface.9ce3d553.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,wEAAK;AAE5B,SAAS,qCAAe,YAAE,QAAQ,UAAE,MAAM,gBAAE,eAAe,OAAO;IAChE,MAAM,aAAa,CAAA,GAAA,oBAAY,EAAE;IAEjC,MAAM,oBAAoB,CAAA,GAAA,iBAAS,EAAE,eAAe;IAEpD,OAAO,wBAAE,yBAAyB;QAChC,wBAAE,CAAA,GAAA,0BAAkB,GAAG;YAAE,UAAU;oBAAU;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;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,aAAa,MAAM,CAAA,GAAA,yCAAQ,GAAG;uBACjC;YACA,WAAW;QACb;QACA,wBAAE,EAAE,CAAC,WAAW,MAAM,CAAA,GAAA,aAAK,GAAG;YAC5B,SAAS;YACT,MAAM;YACN,SAAS;QACX;KACD;AAEL","sources":["packages/map-interface/src/location-panel/header.ts"],"sourcesContent":["import { Icon, Button } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useToaster } from \"@macrostrat/ui-components\";\nimport { LngLatCoords, Elevation } from \"../location-info\";\nimport {\n LocationFocusButton,\n useFocusState,\n isCentered,\n} from \"@macrostrat/mapbox-react\";\nimport classNames from \"classnames\";\nimport type { ReactNode } from \"react\";\nimport type { LngLatBounds, LngLatLike } from \"mapbox-gl\";\n\nconst h = hyper.styled(styles);\n\nfunction PositionButton({ position, bounds, showCopyLink = false }) {\n const focusState = useFocusState(position);\n\n const copyLinkIsVisible = isCentered(focusState) && showCopyLink;\n\n return h(\"div.position-controls\", [\n h(LocationFocusButton, { location: position, bounds, focusState }, []),\n h.if(copyLinkIsVisible && position != null)(CopyLinkButton, {\n itemName: \"position\",\n }),\n ]);\n}\n\nfunction CopyLinkButton({ itemName, children, onClick, ...rest }) {\n const toaster = useToaster();\n\n let message = `Copied link`;\n if (itemName != null) {\n message += ` to ${itemName}`;\n }\n message += \"!\";\n\n return h(\n Button,\n {\n className: \"copy-link-button\",\n rightIcon: h(Icon, { icon: \"link\", size: 12 }),\n minimal: true,\n small: true,\n onClick() {\n navigator.clipboard.writeText(window.location.href).then(\n () => {\n toaster?.show({\n message,\n intent: \"success\",\n icon: \"clipboard\",\n timeout: 1000,\n });\n onClick?.();\n },\n () => {\n toaster?.show({\n message: \"Failed to copy link\",\n intent: \"danger\",\n icon: \"error\",\n timeout: 1000,\n });\n },\n );\n },\n ...rest,\n },\n children ?? \"Copy link\",\n );\n}\n\nexport interface InfoDrawerHeaderProps {\n onClose?: () => void;\n position?: LngLatLike;\n zoom?: number;\n elevation?: number;\n showCopyPositionButton?: boolean;\n bounds?: LngLatBounds;\n fixedHeight?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport function InfoDrawerHeader(props: InfoDrawerHeaderProps) {\n const {\n onClose,\n position,\n bounds,\n zoom = 7,\n elevation,\n showCopyPositionButton,\n fixedHeight = false,\n children,\n className,\n } = props;\n\n let leftButton = null;\n if (bounds != null || position != null) {\n leftButton = h(PositionButton, {\n position,\n bounds,\n showCopyLink: showCopyPositionButton,\n });\n }\n\n return h(\n \"header.location-panel-header\",\n {\n className: classNames(className, { \"fixed-height\": fixedHeight }),\n },\n [\n leftButton,\n children,\n h(\"div.spacer\"),\n h.if(position != null)(LngLatCoords, {\n position,\n zoom,\n className: \"infodrawer-header-item\",\n }),\n h.if(elevation != null)(Elevation, {\n elevation,\n className: \"infodrawer-header-item\",\n }),\n h.if(onClose != null)(Button, {\n minimal: true,\n icon: \"cross\",\n onClick: onClose,\n }),\n ],\n );\n}\n"],"names":[],"version":3,"file":"map-interface.e1493866.js.map"}