@macrostrat/map-interface 0.0.7 → 0.0.9
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/dist/index.css +384 -384
- package/dist/index.css.map +1 -1
- package/dist/index.js +236 -185
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/container.ts +0 -5
- package/src/dev/index.ts +4 -179
- package/src/dev/map-page.ts +181 -0
- package/src/index.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/map-interface",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Map interface for Macrostrat",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -30,14 +30,13 @@
|
|
|
30
30
|
"build": "parcel build"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
|
-
"typescript": "./src/index.ts",
|
|
34
33
|
".": {
|
|
35
34
|
"import": "./dist/index.js",
|
|
36
35
|
"require": "./dist/index.js"
|
|
37
36
|
},
|
|
38
|
-
"./dist/
|
|
39
|
-
"import": "./dist/
|
|
40
|
-
"require": "./dist/
|
|
37
|
+
"./dist/": {
|
|
38
|
+
"import": "./dist/",
|
|
39
|
+
"require": "./dist/"
|
|
41
40
|
}
|
|
42
41
|
},
|
|
43
42
|
"files": [
|
package/src/container.ts
CHANGED
|
@@ -15,10 +15,6 @@ import { Card } from "@blueprintjs/core";
|
|
|
15
15
|
|
|
16
16
|
import { ReactNode } from "react";
|
|
17
17
|
|
|
18
|
-
export * from "./location-panel";
|
|
19
|
-
export * from "./context-panel";
|
|
20
|
-
//export * from "./dev";
|
|
21
|
-
|
|
22
18
|
export function MapInterface() {
|
|
23
19
|
return h("div", "Hello world");
|
|
24
20
|
}
|
|
@@ -136,5 +132,4 @@ export function MapStyledContainer({ className, children }: MapContainerProps) {
|
|
|
136
132
|
return h("div", { className }, children);
|
|
137
133
|
}
|
|
138
134
|
|
|
139
|
-
export * from "./map-view";
|
|
140
135
|
//const _MapPage = compose(HotkeysProvider, MapPage);
|
package/src/dev/index.ts
CHANGED
|
@@ -1,179 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import mapboxgl from "mapbox-gl";
|
|
6
|
-
import { useCallback, useState, useEffect } from "react";
|
|
7
|
-
import { buildInspectorStyle, buildXRayStyle } from "./xray";
|
|
8
|
-
import { MapAreaContainer, PanelCard } from "../container";
|
|
9
|
-
import { FloatingNavbar, MapLoadingButton } from "../context-panel";
|
|
10
|
-
import { MapMarker } from "../helpers";
|
|
11
|
-
import { LocationPanel } from "../location-panel";
|
|
12
|
-
import { MapView } from "../map-view";
|
|
13
|
-
import styles from "./main.module.sass";
|
|
14
|
-
import { TileExtentLayer } from "./tile-extent";
|
|
15
|
-
import {
|
|
16
|
-
FeaturePanel,
|
|
17
|
-
FeatureSelectionHandler,
|
|
18
|
-
TileInfo,
|
|
19
|
-
} from "./vector-tile-features";
|
|
20
|
-
import { MapPosition } from "@macrostrat/mapbox-utils";
|
|
21
|
-
|
|
22
|
-
export enum MacrostratVectorTileset {
|
|
23
|
-
Carto = "carto",
|
|
24
|
-
CartoSlim = "carto-slim",
|
|
25
|
-
IGCPOrogens = "igcp-orogens",
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export enum MacrostratRasterTileset {
|
|
29
|
-
Carto = "carto",
|
|
30
|
-
Emphasized = "emphasized",
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const h = hyper.styled(styles);
|
|
34
|
-
|
|
35
|
-
export function DevMapPage({
|
|
36
|
-
title = "Map inspector",
|
|
37
|
-
headerElement = null,
|
|
38
|
-
transformRequest = null,
|
|
39
|
-
mapPosition = null,
|
|
40
|
-
mapboxToken = null,
|
|
41
|
-
overlayStyle = null,
|
|
42
|
-
children,
|
|
43
|
-
style,
|
|
44
|
-
focusedSource = null,
|
|
45
|
-
focusedSourceTitle = null,
|
|
46
|
-
projection = null,
|
|
47
|
-
}: {
|
|
48
|
-
headerElement?: React.ReactElement;
|
|
49
|
-
transformRequest?: mapboxgl.TransformRequestFunction;
|
|
50
|
-
title?: string;
|
|
51
|
-
style: mapboxgl.Style | string;
|
|
52
|
-
children?: React.ReactNode;
|
|
53
|
-
mapboxToken?: string;
|
|
54
|
-
overlayStyle?: mapboxgl.Style | string;
|
|
55
|
-
focusedSource?: string;
|
|
56
|
-
focusedSourceTitle?: string;
|
|
57
|
-
projection?: string;
|
|
58
|
-
mapPosition?: MapPosition;
|
|
59
|
-
}) {
|
|
60
|
-
/* We apply a custom style to the panel container when we are interacting
|
|
61
|
-
with the search bar, so that we can block map interactions until search
|
|
62
|
-
bar focus is lost.
|
|
63
|
-
We also apply a custom style when the infodrawer is open so we can hide
|
|
64
|
-
the search bar on mobile platforms
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
const dark = useDarkMode();
|
|
68
|
-
const isEnabled = dark?.isEnabled;
|
|
69
|
-
|
|
70
|
-
if (mapboxToken != null) {
|
|
71
|
-
mapboxgl.accessToken = mapboxToken;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
style ??= isEnabled
|
|
75
|
-
? "mapbox://styles/mapbox/dark-v10"
|
|
76
|
-
: "mapbox://styles/mapbox/light-v10";
|
|
77
|
-
|
|
78
|
-
const [isOpen, setOpen] = useState(false);
|
|
79
|
-
|
|
80
|
-
const [state, setState] = useStoredState("macrostrat:dev-map-page", {
|
|
81
|
-
showTileExtent: false,
|
|
82
|
-
xRay: false,
|
|
83
|
-
});
|
|
84
|
-
const { showTileExtent, xRay } = state;
|
|
85
|
-
|
|
86
|
-
const [actualStyle, setActualStyle] = useState(style);
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
buildInspectorStyle(style, overlayStyle, {
|
|
90
|
-
mapboxToken,
|
|
91
|
-
inDarkMode: isEnabled,
|
|
92
|
-
xRay,
|
|
93
|
-
}).then(setActualStyle);
|
|
94
|
-
}, [style, xRay, mapboxToken, isEnabled, overlayStyle]);
|
|
95
|
-
|
|
96
|
-
const [inspectPosition, setInspectPosition] =
|
|
97
|
-
useState<mapboxgl.LngLat | null>(null);
|
|
98
|
-
|
|
99
|
-
const [data, setData] = useState(null);
|
|
100
|
-
|
|
101
|
-
const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {
|
|
102
|
-
setInspectPosition(position);
|
|
103
|
-
}, []);
|
|
104
|
-
|
|
105
|
-
let detailElement = null;
|
|
106
|
-
if (inspectPosition != null) {
|
|
107
|
-
detailElement = h(
|
|
108
|
-
LocationPanel,
|
|
109
|
-
{
|
|
110
|
-
onClose() {
|
|
111
|
-
setInspectPosition(null);
|
|
112
|
-
},
|
|
113
|
-
position: inspectPosition,
|
|
114
|
-
},
|
|
115
|
-
[
|
|
116
|
-
h(TileInfo, {
|
|
117
|
-
feature: data?.[0] ?? null,
|
|
118
|
-
showExtent: showTileExtent,
|
|
119
|
-
setShowExtent() {
|
|
120
|
-
setState({ ...state, showTileExtent: !showTileExtent });
|
|
121
|
-
},
|
|
122
|
-
}),
|
|
123
|
-
h(FeaturePanel, { features: data, focusedSource, focusedSourceTitle }),
|
|
124
|
-
]
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let tile = null;
|
|
129
|
-
if (showTileExtent && data?.[0] != null) {
|
|
130
|
-
let f = data[0];
|
|
131
|
-
tile = { x: f._x, y: f._y, z: f._z };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return h(
|
|
135
|
-
MapAreaContainer,
|
|
136
|
-
{
|
|
137
|
-
navbar: h(FloatingNavbar, [
|
|
138
|
-
headerElement ?? h("h2", title),
|
|
139
|
-
h(Spacer),
|
|
140
|
-
h(MapLoadingButton, {
|
|
141
|
-
active: isOpen,
|
|
142
|
-
onClick: () => setOpen(!isOpen),
|
|
143
|
-
}),
|
|
144
|
-
]),
|
|
145
|
-
contextPanel: h(PanelCard, [
|
|
146
|
-
h(Switch, {
|
|
147
|
-
checked: xRay,
|
|
148
|
-
label: "X-ray mode",
|
|
149
|
-
onChange() {
|
|
150
|
-
setState({ ...state, xRay: !xRay });
|
|
151
|
-
},
|
|
152
|
-
}),
|
|
153
|
-
children,
|
|
154
|
-
]),
|
|
155
|
-
detailPanel: detailElement,
|
|
156
|
-
contextPanelOpen: isOpen,
|
|
157
|
-
},
|
|
158
|
-
h(
|
|
159
|
-
MapView,
|
|
160
|
-
{
|
|
161
|
-
style: actualStyle,
|
|
162
|
-
transformRequest,
|
|
163
|
-
mapPosition,
|
|
164
|
-
projection: "globe",
|
|
165
|
-
},
|
|
166
|
-
[
|
|
167
|
-
h(FeatureSelectionHandler, {
|
|
168
|
-
selectedLocation: inspectPosition,
|
|
169
|
-
setFeatures: setData,
|
|
170
|
-
}),
|
|
171
|
-
h(MapMarker, {
|
|
172
|
-
position: inspectPosition,
|
|
173
|
-
setPosition: onSelectPosition,
|
|
174
|
-
}),
|
|
175
|
-
h(TileExtentLayer, { tile, color: isEnabled ? "white" : "black" }),
|
|
176
|
-
]
|
|
177
|
-
)
|
|
178
|
-
);
|
|
179
|
-
}
|
|
1
|
+
export * from "./map-page";
|
|
2
|
+
export * from "./tile-extent";
|
|
3
|
+
export * from "./vector-tile-features";
|
|
4
|
+
export * from "./xray";
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// Import other components
|
|
2
|
+
import { Switch } from "@blueprintjs/core";
|
|
3
|
+
import hyper from "@macrostrat/hyper";
|
|
4
|
+
import { Spacer, useDarkMode, useStoredState } from "@macrostrat/ui-components";
|
|
5
|
+
import mapboxgl from "mapbox-gl";
|
|
6
|
+
import { useCallback, useState, useEffect } from "react";
|
|
7
|
+
import { buildInspectorStyle, buildXRayStyle } from "./xray";
|
|
8
|
+
import { MapAreaContainer, PanelCard } from "../container";
|
|
9
|
+
import { FloatingNavbar, MapLoadingButton } from "../context-panel";
|
|
10
|
+
import { MapMarker } from "../helpers";
|
|
11
|
+
import { LocationPanel } from "../location-panel";
|
|
12
|
+
import { MapView } from "../map-view";
|
|
13
|
+
import styles from "./main.module.sass";
|
|
14
|
+
import { TileExtentLayer } from "./tile-extent";
|
|
15
|
+
import {
|
|
16
|
+
FeaturePanel,
|
|
17
|
+
FeatureSelectionHandler,
|
|
18
|
+
TileInfo,
|
|
19
|
+
} from "./vector-tile-features";
|
|
20
|
+
import { MapPosition } from "@macrostrat/mapbox-utils";
|
|
21
|
+
|
|
22
|
+
export enum MacrostratVectorTileset {
|
|
23
|
+
Carto = "carto",
|
|
24
|
+
CartoSlim = "carto-slim",
|
|
25
|
+
IGCPOrogens = "igcp-orogens",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export enum MacrostratRasterTileset {
|
|
29
|
+
Carto = "carto",
|
|
30
|
+
Emphasized = "emphasized",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const h = hyper.styled(styles);
|
|
34
|
+
|
|
35
|
+
export function DevMapPage({
|
|
36
|
+
title = "Map inspector",
|
|
37
|
+
headerElement = null,
|
|
38
|
+
transformRequest = null,
|
|
39
|
+
mapPosition = null,
|
|
40
|
+
mapboxToken = null,
|
|
41
|
+
overlayStyle = null,
|
|
42
|
+
children,
|
|
43
|
+
style,
|
|
44
|
+
focusedSource = null,
|
|
45
|
+
focusedSourceTitle = null,
|
|
46
|
+
projection = null,
|
|
47
|
+
}: {
|
|
48
|
+
headerElement?: React.ReactElement;
|
|
49
|
+
transformRequest?: mapboxgl.TransformRequestFunction;
|
|
50
|
+
title?: string;
|
|
51
|
+
style: mapboxgl.Style | string;
|
|
52
|
+
children?: React.ReactNode;
|
|
53
|
+
mapboxToken?: string;
|
|
54
|
+
overlayStyle?: mapboxgl.Style | string;
|
|
55
|
+
focusedSource?: string;
|
|
56
|
+
focusedSourceTitle?: string;
|
|
57
|
+
projection?: string;
|
|
58
|
+
mapPosition?: MapPosition;
|
|
59
|
+
}) {
|
|
60
|
+
/* We apply a custom style to the panel container when we are interacting
|
|
61
|
+
with the search bar, so that we can block map interactions until search
|
|
62
|
+
bar focus is lost.
|
|
63
|
+
We also apply a custom style when the infodrawer is open so we can hide
|
|
64
|
+
the search bar on mobile platforms
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
const dark = useDarkMode();
|
|
68
|
+
const isEnabled = dark?.isEnabled;
|
|
69
|
+
|
|
70
|
+
if (mapboxToken != null) {
|
|
71
|
+
mapboxgl.accessToken = mapboxToken;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
style ??= isEnabled
|
|
75
|
+
? "mapbox://styles/mapbox/dark-v10"
|
|
76
|
+
: "mapbox://styles/mapbox/light-v10";
|
|
77
|
+
|
|
78
|
+
const [isOpen, setOpen] = useState(false);
|
|
79
|
+
|
|
80
|
+
const [state, setState] = useStoredState("macrostrat:dev-map-page", {
|
|
81
|
+
showTileExtent: false,
|
|
82
|
+
xRay: false,
|
|
83
|
+
});
|
|
84
|
+
const { showTileExtent, xRay } = state;
|
|
85
|
+
|
|
86
|
+
const [actualStyle, setActualStyle] = useState(style);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
buildInspectorStyle(style, overlayStyle, {
|
|
90
|
+
mapboxToken,
|
|
91
|
+
inDarkMode: isEnabled,
|
|
92
|
+
xRay,
|
|
93
|
+
}).then(setActualStyle);
|
|
94
|
+
}, [style, xRay, mapboxToken, isEnabled, overlayStyle]);
|
|
95
|
+
|
|
96
|
+
const [inspectPosition, setInspectPosition] =
|
|
97
|
+
useState<mapboxgl.LngLat | null>(null);
|
|
98
|
+
|
|
99
|
+
const [data, setData] = useState(null);
|
|
100
|
+
|
|
101
|
+
const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {
|
|
102
|
+
setInspectPosition(position);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
let detailElement = null;
|
|
106
|
+
if (inspectPosition != null) {
|
|
107
|
+
detailElement = h(
|
|
108
|
+
LocationPanel,
|
|
109
|
+
{
|
|
110
|
+
onClose() {
|
|
111
|
+
setInspectPosition(null);
|
|
112
|
+
},
|
|
113
|
+
position: inspectPosition,
|
|
114
|
+
},
|
|
115
|
+
[
|
|
116
|
+
h(TileInfo, {
|
|
117
|
+
feature: data?.[0] ?? null,
|
|
118
|
+
showExtent: showTileExtent,
|
|
119
|
+
setShowExtent() {
|
|
120
|
+
setState({ ...state, showTileExtent: !showTileExtent });
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
h(FeaturePanel, { features: data, focusedSource, focusedSourceTitle }),
|
|
124
|
+
]
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let tile = null;
|
|
129
|
+
if (showTileExtent && data?.[0] != null) {
|
|
130
|
+
let f = data[0];
|
|
131
|
+
tile = { x: f._x, y: f._y, z: f._z };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
console.log("Style", actualStyle);
|
|
135
|
+
|
|
136
|
+
return h(
|
|
137
|
+
MapAreaContainer,
|
|
138
|
+
{
|
|
139
|
+
navbar: h(FloatingNavbar, [
|
|
140
|
+
headerElement ?? h("h2", title),
|
|
141
|
+
h(Spacer),
|
|
142
|
+
h(MapLoadingButton, {
|
|
143
|
+
active: isOpen,
|
|
144
|
+
onClick: () => setOpen(!isOpen),
|
|
145
|
+
}),
|
|
146
|
+
]),
|
|
147
|
+
contextPanel: h(PanelCard, [
|
|
148
|
+
h(Switch, {
|
|
149
|
+
checked: xRay,
|
|
150
|
+
label: "X-ray mode",
|
|
151
|
+
onChange() {
|
|
152
|
+
setState({ ...state, xRay: !xRay });
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
children,
|
|
156
|
+
]),
|
|
157
|
+
detailPanel: detailElement,
|
|
158
|
+
contextPanelOpen: isOpen,
|
|
159
|
+
},
|
|
160
|
+
h(
|
|
161
|
+
MapView,
|
|
162
|
+
{
|
|
163
|
+
style: actualStyle,
|
|
164
|
+
transformRequest,
|
|
165
|
+
mapPosition,
|
|
166
|
+
projection: "globe",
|
|
167
|
+
},
|
|
168
|
+
[
|
|
169
|
+
h(FeatureSelectionHandler, {
|
|
170
|
+
selectedLocation: inspectPosition,
|
|
171
|
+
setFeatures: setData,
|
|
172
|
+
}),
|
|
173
|
+
h(MapMarker, {
|
|
174
|
+
position: inspectPosition,
|
|
175
|
+
setPosition: onSelectPosition,
|
|
176
|
+
}),
|
|
177
|
+
h(TileExtentLayer, { tile, color: isEnabled ? "white" : "black" }),
|
|
178
|
+
]
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,3 +3,8 @@ export * from "./location-panel";
|
|
|
3
3
|
export * from "./dev";
|
|
4
4
|
export * from "./container";
|
|
5
5
|
export * from "./map-view";
|
|
6
|
+
export * from "./controls";
|
|
7
|
+
export * from "./helpers";
|
|
8
|
+
export * from "./utils";
|
|
9
|
+
export * from "./location-info";
|
|
10
|
+
export * from "./expansion-panel";
|