@@ -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
0 commit comments