Skip to content

Commit 165746b

Browse files
committed
Map centering and zoom
1 parent 61ea651 commit 165746b

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/plugins/aequilibrae/AequilibraEReader.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ const MyComponent = defineComponent({
200200
// Apply default view from config (only switch to map if geometry exists)
201201
if (this.vizDetails.view === 'map' && this.hasGeometry) {
202202
this.viewMode = 'map'
203+
this.setMapCenter()
203204
} else if (this.vizDetails.view === 'table') {
204205
this.viewMode = 'table'
205206
}
@@ -258,8 +259,7 @@ const MyComponent = defineComponent({
258259
}
259260
},
260261
261-
262-
handleFeatureClick(feature: any) {
262+
handleFeatureClick(feature: any) { // TODO: great opportunity to add something cool!
263263
// Handle click on map features
264264
if (!feature) return
265265
console.log('Clicked feature:', feature.properties)
@@ -290,6 +290,25 @@ const MyComponent = defineComponent({
290290
291291
return lines.join('<br/>')
292292
},
293+
294+
setMapCenter() {
295+
let center = this.vizDetails.center
296+
297+
// Handle string format "lon, lat"
298+
if (center && typeof center === 'string') {
299+
center = center.split(',').map((c: string) => parseFloat(c.trim())) as [number, number]
300+
}
301+
302+
if (center && Array.isArray(center) && center.length === 2) {
303+
globalStore.commit('setMapCamera', {
304+
longitude: center[0],
305+
latitude: center[1],
306+
zoom: this.vizDetails.zoom || 9,
307+
bearing: this.vizDetails.bearing || 0,
308+
pitch: this.vizDetails.pitch || 0,
309+
})
310+
}
311+
},
293312
},
294313
})
295314

src/plugins/aequilibrae/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ export interface VizDetails {
1717
database: string;
1818
view: 'table' | 'map' | '';
1919
layers: { [key: string]: LayerConfig };
20+
center?: [number, number];
21+
zoom?: number;
22+
projection?: string;
23+
bearing?: number;
24+
pitch?: number;
2025
}

0 commit comments

Comments
 (0)