@@ -66,8 +66,7 @@ const map = computed(() => mapInstance.value)
6666provide (' map' , map)
6767
6868function onMapCreated (map ) {
69- console .log (' [MapComponent] onMapCreated called' )
70- mapInstance .value = map
69+ mapInstance .value = map
7170
7271 // Create popup instance for hover
7372 hoverPopup .value = new mapboxgl.Popup ({
@@ -78,19 +77,13 @@ function onMapCreated(map) {
7877
7978 // Listen for style changes (when basemap is changed)
8079 map .on (' style.load' , () => {
81- console .log (' [MapComponent] style.load event fired' )
82- console .log (' [MapComponent] Current layers on map:' , map .getStyle ().layers ? .map (l => l .id ) || [])
83- console .log (' [MapComponent] Current sources on map:' , Object .keys (map .getStyle ().sources || {}))
84-
8580 // Increment counter to force MapLayer components to re-render with new keys
8681 styleChangeCounter .value ++
87- console .log (' [MapComponent] Style change counter incremented to:' , styleChangeCounter .value )
8882
8983 // Wait for style to be fully loaded before re-initializing layers
9084 // MapboxLayer components need the style to be ready before they can add layers
9185 const waitForStyleReady = () => {
9286 if (map .isStyleLoaded ()) {
93- console .log (' [MapComponent] Style is ready, re-initializing layers' )
9487 // Clear existing layers from store to force re-render
9588 mapStore .mapboxLayers = []
9689 // Small delay to ensure MapboxLayer components have time to clean up
@@ -99,7 +92,6 @@ function onMapCreated(map) {
9992 initializeMap ()
10093 }, 50 )
10194 } else {
102- console .log (' [MapComponent] Style not ready yet, waiting...' )
10395 setTimeout (waitForStyleReady, 50 )
10496 }
10597 }
@@ -108,49 +100,28 @@ function onMapCreated(map) {
108100
109101 // Wait for initial style to load before adding sources/layers
110102 if (map .isStyleLoaded ()) {
111- console .log (' [MapComponent] Style already loaded, initializing immediately' )
112103 setupActiveLocationLayer ()
113104 initializeMap ()
114105 } else {
115- console .log (' [MapComponent] Style not loaded yet, waiting for style.load event' )
116106 map .once (' style.load' , () => {
117- console .log (' [MapComponent] Initial style.load event fired' )
118107 setupActiveLocationLayer ()
119108 initializeMap ()
120109 })
121110 }
122111}
123112
124113function initializeMap () {
125- console .log (' [MapComponent] initializeMap called' )
126- const mapObj = mapInstance .value
127- console .log (' [MapComponent] Map instance available:' , !! mapObj)
128- console .log (' [MapComponent] Map style loaded:' , mapObj? .isStyleLoaded ())
129-
130114 mapStore .initializeMapboxLayers ()
131- console .log (' [MapComponent] mapboxLayers after initializeMapboxLayers:' , mapStore .mapboxLayers .map (l => l .id ))
132-
133115 locationsStore .fetchLocations ().then (() => {
134- console .log (' [MapComponent] Locations fetched, refreshing layers' )
135- console .log (' [MapComponent] Locations count:' , locationsStore .locations .length )
136116 mapStore .refreshLayers ()
137- console .log (' [MapComponent] Layers refreshed, mapboxLayers:' , mapStore .mapboxLayers .map (l => l .id ))
138117 })
139118}
140119
141120// Setup active-location layer for highlighting selected location
142121function setupActiveLocationLayer () {
143122 const mapObj = mapInstance .value
144- console .log (' [MapComponent] setupActiveLocationLayer called' )
145- console .log (' [MapComponent] Map object available:' , !! mapObj)
146- console .log (' [MapComponent] active-location source exists:' , !! mapObj? .getSource (' active-location' ))
147-
148- if (! mapObj || mapObj .getSource (' active-location' )) {
149- console .log (' [MapComponent] Skipping setupActiveLocationLayer - map not available or source already exists' )
150- return
151- }
123+ if (! mapObj || mapObj .getSource (' active-location' )) return
152124
153- console .log (' [MapComponent] Adding active-location source and layer' )
154125 mapObj .addSource (' active-location' , {
155126 type: ' geojson' ,
156127 data: { type: ' FeatureCollection' , features: [] },
@@ -166,7 +137,6 @@ function setupActiveLocationLayer() {
166137 ' circle-stroke-color' : ' #ff0000' ,
167138 },
168139 })
169- console .log (' [MapComponent] active-location layer added successfully' )
170140}
171141
172142// Handle click on location layer
@@ -261,33 +231,21 @@ function handleLayerMouseleave(layerId) {
261231
262232// Function to update locations layer source data with filtered locations
263233function updateLocationsSourceData () {
264- console .log (' [MapComponent] updateLocationsSourceData called' )
265234 const mapObj = mapInstance .value
266- console .log (' [MapComponent] Map object available:' , !! mapObj)
267- console .log (' [MapComponent] locations-layer exists:' , !! mapObj? .getLayer (' locations-layer' ))
268-
269235 if (! mapObj || ! mapObj .getLayer (' locations-layer' )) {
270- console .log (' [MapComponent] Cannot update source data - map or layer not available' )
271236 return
272237 }
273238
274239 const layer = mapObj .getLayer (' locations-layer' )
275240 const sourceId = layer .source || ' locations-layer'
276241 const source = mapObj .getSource (sourceId)
277242
278- console .log (' [MapComponent] Source ID:' , sourceId)
279- console .log (' [MapComponent] Source exists:' , !! source)
280- console .log (' [MapComponent] Source type:' , source? .type )
281-
282243 if (! source || source .type !== ' geojson' ) {
283- console .log (' [MapComponent] Cannot update source data - source not available or wrong type' )
284244 return
285245 }
286246
287247 const featureCollection = locationsStore .locationsFeatureCollection
288- console .log (' [MapComponent] Setting source data with' , featureCollection .features ? .length || 0 , ' features' )
289248 source .setData (featureCollection)
290- console .log (' [MapComponent] Source data updated successfully' )
291249}
292250
293251
@@ -372,23 +330,17 @@ let setupInProgress = false // Flag to prevent concurrent setups
372330watch (
373331 () => mapboxLayers .value .find (l => l .id === ' locations-layer' ),
374332 (locationsLayer , oldLocationsLayer ) => {
375- console .log (' [MapComponent] Watcher triggered for locations-layer' )
376- console .log (' [MapComponent] locationsLayer found:' , !! locationsLayer)
377- console .log (' [MapComponent] mapInstance available:' , !! mapInstance .value )
378-
379333 // Only reset if layer state actually changed (not found → found)
380334 const wasFound = !! oldLocationsLayer
381335 const isFound = !! locationsLayer
382336
383337 if (! wasFound && isFound) {
384338 // Layer just appeared, reset flags
385- console .log (' [MapComponent] Layer state changed: not found → found, resetting flags' )
386339 locationsLayerListenersAttached = false
387340 retryCount = 0
388341 } else if (wasFound && isFound) {
389342 // Layer already existed, don't reset - might be a duplicate trigger
390343 if (locationsLayerListenersAttached) {
391- console .log (' [MapComponent] Layer already set up, skipping duplicate setup' )
392344 return
393345 }
394346 }
@@ -399,33 +351,27 @@ watch(
399351 const mapObj = mapInstance .value
400352 const layerExists = mapObj? .getLayer (' locations-layer' )
401353 const styleLoaded = mapObj? .isStyleLoaded ()
402- console .log (' [MapComponent] checkAndSetup - locations-layer exists:' , !! layerExists)
403- console .log (' [MapComponent] checkAndSetup - map style loaded:' , styleLoaded)
404354
405355 if (layerExists && styleLoaded) {
406- console .log (' [MapComponent] Setting up locations layer listeners and data' )
407356 retryCount = 0 // Reset on success
408357 setupLocationsLayerListeners ()
409358 updateLocationsSourceData ()
410359
411360 if (mapObj .getLayer (' active-location-layer' ) && mapObj .getLayer (' locations-layer' )) {
412361 try {
413362 mapObj .moveLayer (' active-location-layer' )
414- console .log (' [MapComponent] Moved active-location-layer to top' )
415363 } catch (e) {
416- console . warn ( ' [MapComponent] Layer movement failed: ' , e)
364+ // Layer movement failed, but not critical
417365 }
418366 }
419367 setupInProgress = false // Clear flag on success
420368 } else {
421369 retryCount++
422370 if (retryCount >= MAX_RETRIES ) {
423- console .error (' [MapComponent] Max retries reached, giving up on locations-layer setup' )
424371 retryCount = 0
425372 setupInProgress = false
426373 return
427374 }
428- console .log (` [MapComponent] Layer not ready yet (retry ${ retryCount} /${ MAX_RETRIES } ), retrying in 100ms` )
429375 setTimeout (checkAndSetup, 100 )
430376 }
431377 }
0 commit comments