Skip to content

Commit 4902921

Browse files
committed
Improved map view styling
1 parent e7c4306 commit 4902921

File tree

7 files changed

+46
-8
lines changed

7 files changed

+46
-8
lines changed

packages/map-interface/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.4.0] - 2025-07-02
8+
9+
- Allow `DevMapPage` to set more options for the map, inherited from Mapbox GL
10+
map options
11+
- Streamline map position management during initialization
12+
- Fix stuck loading spinner at map initialization
13+
- Add new stories for position management
14+
- Make `enableTerrain: false` work correctly
15+
- Improve options for map view styling, by allowing the `className` to be set
16+
and deprecating the auto setting of `#map` ID on the map view.
17+
718
## [1.3.2] - 2025-06-26
819

920
Bugfix for DevMapPage when applying custom styles

packages/map-interface/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/map-interface",
3-
"version": "1.3.2",
3+
"version": "1.4.0",
44
"description": "Map interface for Macrostrat",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

packages/map-interface/src/map-view.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export interface MapViewProps extends MapboxCoreOptions {
6161
style: mapboxgl.StyleSpecification,
6262
) => mapboxgl.StyleSpecification;
6363
loadingIgnoredSources?: string[];
64+
id?: string;
65+
className?: string;
6466
}
6567

6668
export interface MapboxOptionsExt extends MapboxCoreOptions {
@@ -126,12 +128,22 @@ export function MapView(props: MapViewProps) {
126128
transformStyle,
127129
trackResize = true,
128130
loadingIgnoredSources = ["elevationMarker", "crossSectionEndpoints"],
131+
id = "map",
132+
className,
129133
...rest
130134
} = props;
131135
if (enableTerrain) {
132136
terrainSourceID ??= "mapbox-3d-dem";
133137
}
134138

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+
135147
const _mapboxToken = mapboxToken ?? accessToken;
136148

137149
if (_mapboxToken != null) {
@@ -213,23 +225,26 @@ export function MapView(props: MapViewProps) {
213225
// Get map projection
214226
const _projection = mapRef.current?.getProjection()?.name ?? "mercator";
215227

216-
const className = classNames(
228+
const mapClassName = classNames(
217229
{
218230
"is-rotated": mapIsRotated ?? false,
219231
"is-3d-available": is3DAvailable,
220232
},
221233
`${_projection}-projection`,
222234
);
223235

224-
const parentClassName = classNames({
225-
standalone,
226-
});
236+
const parentClassName = classNames(
237+
{
238+
standalone,
239+
},
240+
className,
241+
);
227242

228243
return h(
229244
"div.map-view-container.main-view",
230245
{ ref: parentRef, className: parentClassName },
231246
[
232-
h("div.mapbox-map#map", { ref, className }),
247+
h("div.mapbox-map.map-view", { ref, className: mapClassName, id }),
233248
h(MapLoadingReporter, {
234249
ignoredSources: loadingIgnoredSources,
235250
}),

packages/mapbox-react/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.6.2] - 2025-07-02
8+
9+
- Move internal functions for managing focus state to the
10+
`@macrostrat/mapbox-utils` package
11+
712
## [2.6.1] - 2025-06-25
813

914
- Small improvements to types and styles

packages/mapbox-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/mapbox-react",
3-
"version": "2.6.1",
3+
"version": "2.6.2",
44
"description": "Components to support using Mapbox maps in React",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

packages/mapbox-utils/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.6.0] - 2025-07-02
8+
9+
- Add functions to manage focus state and map positioning, inherited from
10+
`@macrostrat/mapbox-react`
11+
- Add new `updateStyleLayers` helper that merges layers into a map style at
12+
runtime
13+
714
## [1.5.1] - 2025-06-25
815

916
- Fix `getMapPosition` and `setMapPosition` functions

packages/mapbox-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/mapbox-utils",
3-
"version": "1.5.1",
3+
"version": "1.6.0",
44
"description": "Utilities for working with Mapbox maps",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

0 commit comments

Comments
 (0)