@macrostrat/map-interface 0.2.1 → 0.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/dist/index.cjs +28 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -4
- package/dist/index.css.map +1 -1
- package/dist/index.js +32 -29
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/container.ts +0 -4
- package/src/dev/main.module.sass +1 -5
- package/src/dev/map-page.ts +3 -4
- package/src/helpers.ts +1 -1
- package/src/map-view/index.ts +19 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/map-interface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Map interface for Macrostrat",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"classnames": "^2.3.2",
|
|
19
19
|
"d3-array": "^3.2.4",
|
|
20
20
|
"d3-format": "^3.1.0",
|
|
21
|
-
"mapbox-gl": "^2.
|
|
21
|
+
"mapbox-gl": "^2.15.0",
|
|
22
22
|
"transition-hook": "^1.5.2",
|
|
23
23
|
"underscore": "^1.13.6",
|
|
24
24
|
"use-resize-observer": "^9.1.0"
|
package/src/container.ts
CHANGED
|
@@ -35,7 +35,6 @@ function _MapAreaContainer({
|
|
|
35
35
|
mapControls = h(MapBottomControls),
|
|
36
36
|
contextStackProps = null,
|
|
37
37
|
detailStackProps = null,
|
|
38
|
-
mapPosition = null,
|
|
39
38
|
fitViewport = true,
|
|
40
39
|
...rest
|
|
41
40
|
}: {
|
|
@@ -52,7 +51,6 @@ function _MapAreaContainer({
|
|
|
52
51
|
contextPanelOpen?: boolean;
|
|
53
52
|
contextStackProps?: HTMLDivProps;
|
|
54
53
|
detailStackProps?: HTMLDivProps;
|
|
55
|
-
mapPosition?: MapPosition;
|
|
56
54
|
fitViewport?: boolean;
|
|
57
55
|
}) {
|
|
58
56
|
const _detailPanelOpen = detailPanelOpen ?? detailPanel != null;
|
|
@@ -84,7 +82,6 @@ function _MapAreaContainer({
|
|
|
84
82
|
className: classNames("map-page", className, {
|
|
85
83
|
"fit-viewport": fitViewport,
|
|
86
84
|
}),
|
|
87
|
-
mapPosition,
|
|
88
85
|
},
|
|
89
86
|
[
|
|
90
87
|
h("div.main-ui", { className: mainUIClassName, ...rest }, [
|
|
@@ -117,7 +114,6 @@ export const MapAreaContainer = (props) =>
|
|
|
117
114
|
|
|
118
115
|
interface MapContainerProps {
|
|
119
116
|
className?: string;
|
|
120
|
-
mapPosition?: MapPosition;
|
|
121
117
|
children?: ReactNode;
|
|
122
118
|
}
|
|
123
119
|
|
package/src/dev/main.module.sass
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.feature-panel
|
|
2
2
|
position: relative
|
|
3
|
-
|
|
3
|
+
margin: 0 -1em
|
|
4
4
|
|
|
5
5
|
.key-value
|
|
6
6
|
display: inline-block
|
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
.feature-group
|
|
29
29
|
border-bottom: 1px solid var(--panel-rule-inner)
|
|
30
|
-
padding: 0 1em
|
|
31
|
-
margin-left: -1em
|
|
32
|
-
margin-right: -1em
|
|
33
30
|
margin-bottom: 0.5em
|
|
34
31
|
&:last-child
|
|
35
32
|
border-bottom: none
|
|
@@ -38,7 +35,6 @@
|
|
|
38
35
|
display: flex
|
|
39
36
|
flex-direction: row
|
|
40
37
|
align-items: baseline
|
|
41
|
-
padding: 0 1em
|
|
42
38
|
h3
|
|
43
39
|
margin-right: 0.5em
|
|
44
40
|
|
package/src/dev/map-page.ts
CHANGED
|
@@ -48,7 +48,7 @@ export function DevMapPage({
|
|
|
48
48
|
headerElement?: React.ReactElement;
|
|
49
49
|
transformRequest?: mapboxgl.TransformRequestFunction;
|
|
50
50
|
title?: string;
|
|
51
|
-
style
|
|
51
|
+
style?: mapboxgl.Style | string;
|
|
52
52
|
children?: React.ReactNode;
|
|
53
53
|
mapboxToken?: string;
|
|
54
54
|
overlayStyle?: mapboxgl.Style | string;
|
|
@@ -131,8 +131,6 @@ export function DevMapPage({
|
|
|
131
131
|
tile = { x: f._x, y: f._y, z: f._z };
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
console.log("Style", actualStyle);
|
|
135
|
-
|
|
136
134
|
return h(
|
|
137
135
|
MapAreaContainer,
|
|
138
136
|
{
|
|
@@ -163,7 +161,8 @@ export function DevMapPage({
|
|
|
163
161
|
style: actualStyle,
|
|
164
162
|
transformRequest,
|
|
165
163
|
mapPosition,
|
|
166
|
-
projection: "globe",
|
|
164
|
+
projection: { name: "globe" },
|
|
165
|
+
mapboxToken,
|
|
167
166
|
},
|
|
168
167
|
[
|
|
169
168
|
h(FeatureSelectionHandler, {
|
package/src/helpers.ts
CHANGED
|
@@ -10,7 +10,7 @@ import useResizeObserver from "use-resize-observer";
|
|
|
10
10
|
|
|
11
11
|
import { getMapPosition } from "@macrostrat/mapbox-utils";
|
|
12
12
|
import mapboxgl from "mapbox-gl";
|
|
13
|
-
import { useCallback, useEffect, useState
|
|
13
|
+
import { useCallback, useEffect, useState } from "react";
|
|
14
14
|
import { getMapPadding, useMapMarker } from "./utils";
|
|
15
15
|
|
|
16
16
|
export function MapResizeManager({ containerRef }) {
|
package/src/map-view/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
MapResizeManager,
|
|
23
23
|
} from "../helpers";
|
|
24
24
|
import "mapbox-gl/dist/mapbox-gl.css";
|
|
25
|
+
import { getMapPadding } from "../utils";
|
|
25
26
|
|
|
26
27
|
const h = hyper.styled({ ...styles, ...rootStyles });
|
|
27
28
|
|
|
@@ -30,14 +31,19 @@ type MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, "container">;
|
|
|
30
31
|
export interface MapViewProps extends MapboxCoreOptions {
|
|
31
32
|
showLineSymbols?: boolean;
|
|
32
33
|
children?: React.ReactNode;
|
|
34
|
+
mapboxToken?: string;
|
|
35
|
+
// Deprecated
|
|
33
36
|
accessToken?: string;
|
|
34
37
|
terrainSourceID?: string;
|
|
35
38
|
enableTerrain?: boolean;
|
|
36
39
|
infoMarkerPosition?: mapboxgl.LngLatLike;
|
|
37
|
-
//style: mapboxgl.Style | string;
|
|
38
|
-
//transformRequest?: mapboxgl.TransformRequestFunction;
|
|
39
40
|
mapPosition?: MapPosition;
|
|
40
|
-
|
|
41
|
+
initializeMap?: (
|
|
42
|
+
container: HTMLElement,
|
|
43
|
+
args: MapboxOptionsExt
|
|
44
|
+
) => mapboxgl.Map;
|
|
45
|
+
onMapLoaded?: (map: mapboxgl.Map) => void;
|
|
46
|
+
onStyleLoaded?: (map: mapboxgl.Map) => void;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
export interface MapboxOptionsExt extends MapboxCoreOptions {
|
|
@@ -83,6 +89,8 @@ export function MapView(props: MapViewProps) {
|
|
|
83
89
|
mapPosition = defaultMapPosition,
|
|
84
90
|
initializeMap = defaultInitializeMap,
|
|
85
91
|
children,
|
|
92
|
+
mapboxToken,
|
|
93
|
+
// Deprecated
|
|
86
94
|
accessToken,
|
|
87
95
|
infoMarkerPosition,
|
|
88
96
|
transformRequest,
|
|
@@ -95,8 +103,10 @@ export function MapView(props: MapViewProps) {
|
|
|
95
103
|
terrainSourceID ??= "mapbox-3d-dem";
|
|
96
104
|
}
|
|
97
105
|
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
const _mapboxToken = mapboxToken ?? accessToken;
|
|
107
|
+
|
|
108
|
+
if (_mapboxToken != null) {
|
|
109
|
+
mapboxgl.accessToken = _mapboxToken;
|
|
100
110
|
}
|
|
101
111
|
|
|
102
112
|
const dispatch = useMapDispatch();
|
|
@@ -105,6 +115,9 @@ export function MapView(props: MapViewProps) {
|
|
|
105
115
|
const parentRef = useRef<HTMLDivElement>();
|
|
106
116
|
|
|
107
117
|
// Keep track of map position for reloads
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
console.log("Map updated", mapRef.current);
|
|
120
|
+
}, [mapRef.current]);
|
|
108
121
|
|
|
109
122
|
useEffect(() => {
|
|
110
123
|
if (style == null) return;
|
|
@@ -119,6 +132,7 @@ export function MapView(props: MapViewProps) {
|
|
|
119
132
|
mapPosition,
|
|
120
133
|
...rest,
|
|
121
134
|
});
|
|
135
|
+
map.setPadding(getMapPadding(ref, parentRef), { animate: false });
|
|
122
136
|
map.on("style.load", () => {
|
|
123
137
|
onStyleLoaded?.(map);
|
|
124
138
|
dispatch({ type: "set-style-loaded", payload: true });
|