{"record":{"id":"d7c061f78c65af36","repo":"Freika/dawarich","slug":"realtime-controller-map-not-available-for-zoomin","errorCode":null,"errorMessage":"[Realtime Controller] Map not available for zooming","messagePattern":"\\[Realtime Controller\\] Map not available for zooming","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/controllers/maps/maplibre_realtime_controller.js","lineNumber":290,"sourceCode":"      mapsController.layerManager?.getLayer(\"recentPoint\")\n    if (!recentPointLayer) {\n      console.warn(\"[Realtime Controller] Recent point layer not found\")\n      return\n    }\n\n    if (this.liveModeEnabled) {\n      recentPointLayer.show()\n      recentPointLayer.updateRecentPoint(longitude, latitude, properties)\n    }\n  }\n\n  /**\n   * Zoom map to a specific point\n   */\n  zoomToPoint(longitude, latitude) {\n    const mapsController = this.mapsV2Controller\n    if (!mapsController || !mapsController.map) {\n      console.warn(\"[Realtime Controller] Map not available for zooming\")\n      return\n    }\n\n    const map = mapsController.map\n\n    map.flyTo({\n      center: [longitude, latitude],\n      zoom: Math.max(map.getZoom(), 14),\n      duration: 2000,\n      essential: true,\n    })\n  }\n\n  /**\n   * Update connection indicator (no-op, badge removed)\n   */\n  updateConnectionIndicator(_connected) {}\n}","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/controllers/maps/maplibre_realtime_controller.js#L272-L308","documentation":"zoomToPoint guards on !mapsController || !mapsController.map before calling map.flyTo. The map property only exists after maplibregl.Map construction finishes inside the maps controller's async initialization, so this warning means a zoom request (e.g. live-mode jump to newest point or a replay seek) arrived before the MapLibre GL map instance was created. The zoom is silently skipped.","triggerScenarios":"A realtime broadcast or UI action invokes zoomToPoint during page load before maplibre_controller has assigned this.map; or the map controller exists but failed to initialize its map (bad container, missing token/style error) leaving map undefined while live mode keeps calling zoom.","commonSituations":"Live mode auto-zoom enabled with a phone uploading points the moment the page opens; map container hidden at init (display:none tab) preventing MapLibre setup; style URL failure so map never instantiates yet realtime handlers keep firing.","solutions":["Queue the zoom request (store target coords) and execute it on the MapLibre map's first 'load' event, so early broadcasts are not lost.","Only call zoomToPoint after the map controller dispatches its ready state; check mapsController.map upfront at the call site.","If map stays undefined permanently, check the browser console for MapLibre init errors (missing style, invalid container) and fix those first."],"exampleFix":"// before\nzoomToPoint(longitude, latitude) {\n  const mapsController = this.mapsV2Controller\n  if (!mapsController || !mapsController.map) {\n    console.warn(\"[Realtime Controller] Map not available for zooming\")\n    return\n  }\n  ...\n}\n\n// after\nzoomToPoint(longitude, latitude) {\n  const mapsController = this.mapsV2Controller\n  if (!mapsController || !mapsController.map) {\n    this.pendingZoom = [longitude, latitude]\n    return\n  }\n  ...\n}\n// on map 'load': if (this.pendingZoom) { const [lo, la] = this.pendingZoom; this.zoomToPoint(lo, la) }","handlingStrategy":"fallback","validationCode":"const m = this.mapsV2Controller?.map\nif (!m) { this.pendingZoom = [longitude, latitude]; return }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call flyTo without confirming the map instance and its loaded state.","Queue UI-driven zooms that occur during init and replay them on the map 'load' event."],"tags":["maplibre","realtime","initialization-order","flyto"],"backgroundTag":"map-not-initialized","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}