maps: render ambient POIs natively from the baked ma_pois PMTiles layer (reuse single vector source, drop slow offline-index pins); default cold-start camera to SF for testing
- Commit
4571ead8da2f4b2c344fe9b57c932f1501b14dc8- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-18 15:40 UTC (3 months ago)
- Parents
196bbae
Diff
maps/src/main/java/com/vayunmathur/maps/ui/MaPoisLayer.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MaPoisLayer.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MaPoisLayer.ktindex 551b80fa46..ee5fbfb20f 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MaPoisLayer.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MaPoisLayer.kt@@ -2,10 +2,8 @@ package com.vayunmathur.maps.ui import androidx.compose.runtime.Composable import androidx.compose.runtime.remember-import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asImageBitmap-import androidx.compose.ui.unit.dp import com.vayunmathur.maps.data.Feature1 import com.vayunmathur.maps.data.SpecificFeature import com.vayunmathur.maps.data.string@@ -20,8 +18,6 @@ import org.maplibre.compose.expressions.dsl.linear import org.maplibre.compose.expressions.dsl.switch import org.maplibre.compose.expressions.dsl.zoom import org.maplibre.compose.expressions.value.IntValue-import org.maplibre.compose.expressions.value.StringValue-import org.maplibre.compose.expressions.value.SymbolAnchor import org.maplibre.compose.layers.SymbolLayer import org.maplibre.compose.sources.VectorSource import org.maplibre.compose.util.MaplibreComposable@@ -31,7 +27,6 @@ import org.maplibre.spatialk.geojson.Position /** Symbol layer id for the OSM POI icons — hit-tested in MapPage.onMapClick so a * POI tap selects the place (name/coord) and fetches Google rich details. */ const val MA_POIS_LAYER_ID = "ma-pois-icons"-private const val MA_POIS_LABEL_LAYER_ID = "ma-pois-labels" /** * OUR baked OSM POI layer (P27). Placement / name / type come from the@@ -49,9 +44,11 @@ object MaPoisSource { /** * Draw the `ma_pois` source-layer: a category icon per feature (data-driven off- * the numeric `type`, see [PoiCategories]) plus a name label, from z12 up. Reads- * the same shared [VectorSource] the admin/transit overlays use. Harmless no-op- * while the source-layer is absent (until v5 is regenerated with `ma_pois`).+ * the numeric `type`, see [PoiCategories]), from z12 up. Reads the SAME shared+ * [VectorSource] the admin/transit overlays use (single source — a second source+ * on the same PMTiles triggers a directory parse error). The disc icons are+ * runtime Canvas bitmaps (no sprite/glyph assets needed), so this renders even+ * while the style's remote glyphs 404; the POI NAME is shown in the sheet on tap. */ @Composable @MaplibreComposable@@ -78,19 +75,6 @@ fun MaPoisLayer(source: VectorSource) { 18 to const(0.7f), ), )-- // Name label under the icon.- SymbolLayer(- MA_POIS_LABEL_LAYER_ID,- source,- sourceLayer = MaPoisSource.SOURCE_LAYER,- minZoom = 14f,- textField = feature["name"].cast<StringValue>(),- textColor = const(Color(0xFF37474F)),- textHaloColor = const(Color.White),- textHaloWidth = const(1.5.dp),- textAnchor = const(SymbolAnchor.Top),- ) } /**
maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.ktindex c7d9e6131c..e076acc4f3 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt@@ -147,12 +147,6 @@ fun MapPage(backStack: NavBackStack<Route>, viewModel: SelectedFeatureViewModel, val selectedTransitStop by transitViewModel.selected.collectAsState() val departuresState by transitViewModel.departures.collectAsState() - // Ambient POI pins (P29): now sourced from the OFFLINE POI index- // (poi_index.bin) via GooglePoiMapViewModel.onViewportOffline as the camera- // moves, and rendered by GooglePoiLayer (the proven GeoJSON pin renderer).- // This replaces the P27 baked `ma_pois` PMTiles layer, which failed to render.- val googlePins by poiViewModel.pins.collectAsState()- // Search-result pins (from the Google search page) drawn on the map. val searchResults by searchViewModel.results.collectAsState() @@ -161,7 +155,9 @@ fun MapPage(backStack: NavBackStack<Route>, viewModel: SelectedFeatureViewModel, // and pushes updates only while bound. Empty when findfamily is absent. val familyMembers by com.vayunmathur.maps.ipc.rememberFamilyMembers() - val camera = rememberCameraState(CameraPosition(target = Position(-118.243683,34.052235), zoom = 5.0))+ // TEST: default to San Francisco at z14 so the native ma_pois POIs are+ // visible on cold start.+ val camera = rememberCameraState(CameraPosition(target = Position(-122.4194, 37.7749), zoom = 14.0)) LaunchedEffect(camera.position, transitEnabled) { if (camera.position.zoom >= 11.0) {@@ -169,9 +165,10 @@ fun MapPage(backStack: NavBackStack<Route>, viewModel: SelectedFeatureViewModel, val projection = camera.projection if (projection != null) { val bbox = projection.queryVisibleBoundingBox()- // Ambient POI pins (P29): query the OFFLINE index for the visible- // box and publish pins for GooglePoiLayer. Only at zoom >= 11.- poiViewModel.onViewportOffline(bbox.north, bbox.east, bbox.south, bbox.west)+ // Ambient POIs (P29) are now rendered NATIVELY from the baked+ // `ma_pois` PMTiles source-layer (see MaPoisLayer in MyMapLayers),+ // so no per-viewport offline-index query is needed here. PoiIndex+ // is still used for offline SEARCH only. // Refresh nearby transit stops (P10) only while the layer is on // (VM debounces + caches; wide views clear the overlay). if (transitEnabled) {@@ -181,9 +178,9 @@ fun MapPage(backStack: NavBackStack<Route>, viewModel: SelectedFeatureViewModel, } } - // P29: ambient POIs now come from the OFFLINE POI index (poi_index.bin),- // queried per-viewport and rendered via the proven GooglePoiLayer, replacing- // the P27 baked `ma_pois` PMTiles layer (which failed to parse/render).+ // Offline POI SEARCH index (poi_index.bin / poi_names.bin, P27). Ambient POI+ // rendering is now native from the baked `ma_pois` PMTiles source-layer (see+ // MaPoisLayer), so this index is only used to answer offline search queries. // Re-map the side files once the map is ready so a first-run download that // landed AFTER PoiIndex.initialize first ran (and no-op'd because the files // were absent) is picked up instead of staying poisoned. reload() is a cheap@@ -521,8 +518,8 @@ fun MapPage(backStack: NavBackStack<Route>, viewModel: SelectedFeatureViewModel, )?.firstNotNullOfOrNull { it.toSelectedFamilyMember() } ?: projection?.queryRenderedFeatures( offset,- setOf(GOOGLE_POI_LAYER_ID)- )?.firstNotNullOfOrNull { it.toSelectedGooglePoi() }+ setOf(MA_POIS_LAYER_ID)+ )?.firstNotNullOfOrNull { it.toSelectedMaPoi() } if (pinHit != null) { if (selectedFeature is SpecificFeature.Route) viewModel.setInactiveNavigation( selectedFeature as SpecificFeature.Route@@ -577,7 +574,7 @@ fun MapPage(backStack: NavBackStack<Route>, viewModel: SelectedFeatureViewModel, ClickResult.Pass } ) {- MyMapLayers(selectedFeature, route?.get(selectedRouteType), json, userPosition, userBearing, navProgress, googlePins, searchResults, savedPins, parkingSpot, transitStops, familyMembers, trafficEnabled, satelliteEnabled, safetyEnabled, transitEnabled)+ MyMapLayers(selectedFeature, route?.get(selectedRouteType), json, userPosition, userBearing, navProgress, searchResults, savedPins, parkingSpot, transitStops, familyMembers, trafficEnabled, satelliteEnabled, safetyEnabled, transitEnabled) } }
maps/src/main/java/com/vayunmathur/maps/ui/MyMapLayers.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MyMapLayers.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MyMapLayers.ktindex 5a56edee6b..27ddcd9ed5 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MyMapLayers.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MyMapLayers.kt@@ -12,7 +12,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import com.vayunmathur.maps.data.Feature1 import com.vayunmathur.maps.data.SpecificFeature-import com.vayunmathur.maps.data.google.GooglePoiPin import com.vayunmathur.maps.data.google.GoogleTrafficSource import com.vayunmathur.maps.util.MapTileCache import com.vayunmathur.maps.util.OfflineRouter@@ -57,7 +56,6 @@ fun MyMapLayers( userPosition: Position, userBearing: Float, navProgress: com.vayunmathur.maps.util.NavigationProgress? = null,- googlePins: List<GooglePoiPin> = emptyList(), searchResults: List<SearchResult> = emptyList(), savedPlaces: List<com.vayunmathur.maps.data.SavedPlace> = emptyList(), parkingSpot: com.vayunmathur.maps.data.ParkingSpot? = null,@@ -145,14 +143,14 @@ fun MyMapLayers( TransitLinesLayer(adminSource) } - // Ambient POI overlay (P29): pins now come from the OFFLINE POI index- // (poi_index.bin, queried per-viewport by GooglePoiMapViewModel) and are- // drawn through GooglePoiLayer — the proven GeoJSON pin renderer. This- // replaces the P27 baked `ma_pois` PMTiles SymbolLayer, which failed to- // render (PMTiles directory parse error on the overlay source). Google is- // still hit only on tap for rich details (see MapPage.onMapClick ->- // toSelectedGooglePoi).- GooglePoiLayer(googlePins)+ // Ambient POI overlay (P29): rendered NATIVELY from the baked `ma_pois`+ // PMTiles source-layer (P27) via the EXISTING single vector source+ // (`adminSource`) — the same one the admin/transit overlays reuse. This+ // avoids the second-source "PMTiles directory" parse error that broke the+ // original overlay, and it removes the slow per-viewport offline-index+ // GeoJSON pins path. Google is still hit only on tap for rich details+ // (see MapPage.onMapClick -> toSelectedMaPoi).+ MaPoisLayer(adminSource) // Saved-place pins (Home / Work / starred list). Tap re-selects the // place → PlaceSheet (Vela's SavedPin).