Update map view defaults, add terrain support, and configure pitch settings

This commit is contained in:
geoffsee
2025-07-17 18:30:18 -04:00
parent 5b896d9d07
commit da32a5d780
2 changed files with 20 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ import Map, {
NavigationControl, NavigationControl,
Popup, Popup,
ScaleControl, ScaleControl,
Source,
} from 'react-map-gl/mapbox'; } from 'react-map-gl/mapbox';
import clientChatStore from '../../stores/ClientChatStore'; import clientChatStore from '../../stores/ClientChatStore';
@@ -122,6 +123,8 @@ Type '{ city: string; population: string; image: string; state: string; latitude
pitch: clientChatStore.mapState.pitch, pitch: clientChatStore.mapState.pitch,
}} }}
onMove={handleMapViewChange} onMove={handleMapViewChange}
terrain={{ source: 'mapbox-dem', exaggeration: 1.5 }}
maxPitch={85}
mapStyle="mapbox://styles/geoffsee/cmd1qz39x01ga01qv5acea02y" mapStyle="mapbox://styles/geoffsee/cmd1qz39x01ga01qv5acea02y"
attributionControl={false} attributionControl={false}
mapboxAccessToken={props.mapboxPublicKey} mapboxAccessToken={props.mapboxPublicKey}
@@ -135,6 +138,13 @@ Type '{ city: string; population: string; image: string; state: string; latitude
right: 0, right: 0,
}} }}
> >
<Source
id="mapbox-dem"
type="raster-dem"
url="mapbox://mapbox.mapbox-terrain-dem-v1"
tileSize={512}
maxzoom={14}
/>
<GeolocateControl position="top-left" style={{ marginTop: '6rem' }} /> <GeolocateControl position="top-left" style={{ marginTop: '6rem' }} />
<FullscreenControl position="top-left" /> <FullscreenControl position="top-left" />
<NavigationControl position="top-left" /> <NavigationControl position="top-left" />

View File

@@ -9,26 +9,31 @@ export interface MapControlCommand {
export const MapStore = types export const MapStore = types
.model('MapStore', { .model('MapStore', {
// Current map view state // Current map view state
longitude: types.optional(types.number, -122.4), // 37°47'21"N 122°23'52"W
latitude: types.optional(types.number, 37.8), longitude: types.optional(types.number, -87.6319),
zoom: types.optional(types.number, 14), latitude: types.optional(types.number, 41.883415),
zoom: types.optional(types.number, 14.5),
bearing: types.optional(types.number, 15.165878375019094),
pitch: types.optional(types.number, 45),
// Map control state // Map control state
isControlActive: types.optional(types.boolean, false), isControlActive: types.optional(types.boolean, false),
}) })
.volatile(self => ({ .volatile(self => ({
// Store pending map commands from AI // Store pending map commands from AI
pendingCommands: [] as MapControlCommand[], pendingCommands: [] as MapControlCommand[],
// 41.88341413374059-87.630091075785714.57273962016686450
mapState: { mapState: {
latitude: self.latitude, latitude: self.latitude,
longitude: self.longitude, longitude: self.longitude,
zoom: self.zoom, zoom: self.zoom,
bearing: 0, bearing: self.bearing,
pitch: 0, pitch: self.pitch,
} as any, } as any,
})) }))
.actions(self => ({ .actions(self => ({
// Update map view state // Update map view state
setMapView(longitude: number, latitude: number, zoom: number) { setMapView(longitude: number, latitude: number, zoom: number) {
console.log(latitude, longitude, zoom, self.mapState.pitch, self.mapState.bearing);
self.longitude = longitude; self.longitude = longitude;
self.latitude = latitude; self.latitude = latitude;
self.zoom = zoom; self.zoom = zoom;