Skip to content

Commit f0c4d71

Browse files
committed
Set ohm mapbase by default
1 parent aa3497d commit f0c4d71

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

src/components/changeset/map_options.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const toggle = (arr, elem) => {
2424

2525
class MapOptions extends React.PureComponent {
2626
layerOptions = [
27+
{ label: 'OpenHistoricalMap', value: 'ohm' },
2728
{ label: 'Bing aerial imagery', value: 'bing' },
2829
{ label: 'OpenStreetMap Carto', value: 'carto' }
2930
];

src/views/changeset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Changeset extends React.PureComponent {
3939
// map configuration state (set in the map options panel and used in the CMap view)
4040
showElements: ['node', 'way', 'relation'],
4141
showActions: ['create', 'modify', 'delete', 'noop'],
42-
basemapStyle: 'bing'
42+
basemapStyle: 'ohm'
4343
};
4444

4545
// This ref is passed to CMap, which updates it with references to the MapLibre map

src/views/map.js

+25-10
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,46 @@ class CMap extends React.PureComponent {
109109
}
110110
}
111111

112-
initializeMap() {
113-
if (!this.props.changeset) {
114-
return;
115-
}
112+
async initializeMap() {
113+
if (!this.props.changeset) return;
116114

117115
let container = document.getElementById('container');
118116

119117
if (this.map) {
120118
this.map.remove();
121119
}
122120

123-
let style = BING_AERIAL_IMAGERY_STYLE;
121+
let style;
124122

125-
if (this.props.style === 'carto') {
123+
const styleType = 'ohm';
124+
125+
if (styleType === 'carto') {
126126
style = OPENSTREETMAP_CARTO_STYLE;
127+
} else if (styleType === 'ohm') {
128+
try {
129+
const response = await fetch(
130+
'https://www.openhistoricalmap.org/map-styles/main/main.json'
131+
);
132+
style = await response.json();
133+
} catch (err) {
134+
console.error('Failed to load OHM style:', err);
135+
this.props.modal({
136+
kind: 'error',
137+
title: 'Failed to load map style',
138+
description: 'Could not load OpenHistoricalMap style.'
139+
});
140+
return;
141+
}
142+
} else {
143+
style = BING_AERIAL_IMAGERY_STYLE;
127144
}
128145

129146
let map = new maplibre.Map({
130147
container,
131148
style,
132149
maxZoom: 22,
133150
hash: false,
134-
attributionControl: false // we're moving this to the other corner
151+
attributionControl: false
135152
});
136153

137154
map.addControl(new maplibre.AttributionControl(), 'bottom-left');
@@ -142,9 +159,9 @@ class CMap extends React.PureComponent {
142159
map.keyboard.disableRotation();
143160

144161
let { adiff } = this.props.changeset;
145-
// HACK: override attribution string (the string Overpass sends is wordier and doesn't have a hyperlink)
146162
adiff.note =
147163
'Map data from <a href=https://openstreetmap.org/copyright>OpenStreetMap</a>';
164+
148165
const adiffViewer = new MapLibreAugmentedDiffViewer(adiff, {
149166
onClick: this.handleClick,
150167
showElements: this.props.showElements,
@@ -181,8 +198,6 @@ class CMap extends React.PureComponent {
181198
this.map = map;
182199
this.adiffViewer = adiffViewer;
183200

184-
// Store the map and adiffViewer in the ref passed from the parent component
185-
// (this allows other components to imperatively update the map state)
186201
if (this.props.mapRef) {
187202
this.props.mapRef.current = {
188203
map: this.map,

0 commit comments

Comments
 (0)