Skip to content

Commit

Permalink
make it easier to hit the right line in overlays (workaround, fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Aug 29, 2024
1 parent 771fb07 commit 327a11c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ class MainMapFragment : MapFragment(), ShowsGeometryMarkers {
private const val MIN_TRACK_ACCURACY = 20f
private const val MAX_TIME_BETWEEN_LOCATIONS = 60L * 1000 // 1 minute

private const val CLICK_AREA_SIZE_IN_DP = 24
private const val CLICK_AREA_SIZE_IN_DP = 28
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ fun MapLibreMap.queryRenderedFeatures(
radius: Float,
vararg layerIds: String
): List<Feature> {
val searchArea = RectF(
coordinates.x - radius,
coordinates.y - radius,
coordinates.x + radius,
coordinates.y + radius
)
return queryRenderedFeatures(searchArea, *layerIds)
// first try without radius. If nothing found, only then expand search area
var result = queryRenderedFeatures(coordinates, *layerIds)
if (result.isNotEmpty()) return result
// then, try with small radius....
result = queryRenderedFeatures(coordinates.expandBy(radius/2), *layerIds)

Check failure on line 24 in app/src/main/java/de/westnordost/streetcomplete/screens/main/map/maplibre/MapLibreMap.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Missing spacing around "/"
if (result.isNotEmpty()) return result

return queryRenderedFeatures(coordinates.expandBy(radius), *layerIds)

// this is kind of a workaround. We'd need is this function implemented in MapLibre proper. See
// https://github.com/maplibre/maplibre-native/issues/2781
}

private fun PointF.expandBy(a: Float) = RectF(x - a, y - a, x + a, y + a)

0 comments on commit 327a11c

Please sign in to comment.