maps: hit-slop on label taps so city names select, not coordinates
- Commit
eaf17d95101f78430b767768c5498b8069e826c7- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-21 21:46 UTC (2 months ago)
- Parents
5c5a06b
Diff
maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.ktindex 4e118bd84c..4829e2eddd 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt@@ -8,7 +8,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.unit.DpRect-import androidx.compose.ui.unit.DpSize+import com.vayunmathur.maps.ui.theme.MapChromeMetrics import com.vayunmathur.library.map.CameraState import com.vayunmathur.library.map.GeoPoint import com.vayunmathur.library.map.LayerOptions@@ -299,9 +299,14 @@ fun MapSurface( // when nothing is, it falls through to reverse-geocode exactly like a // blank tap. // to reverse-geocode exactly like a blank tap.+ // A slop box, not the bare point: a place label is a thin line of text, and a+ // zero-size query only hit when the finger landed exactly on a glyph — so a tap+ // "on" a city almost always fell through to reverse-geocode. The same+ // [MapChromeMetrics.hitSlop] the pin picker uses makes tapping the name select it.+ val slop = MapChromeMetrics.hitSlop val label = viewModel.resolveAdminLabel( projection.queryRenderedLabels(- DpRect(offset, DpSize.Zero),+ DpRect(offset.x - slop, offset.y - slop, offset.x + slop, offset.y + slop), NATIVE_LABEL_LAYER_IDS, ).mapNotNull { it.toFeature1() } )