refactor: scale requiredZoomLevel() by 0.8 to improve fit

This commit is contained in:
andrekir 2024-11-04 12:57:00 -03:00
parent 45d3741124
commit d4137a7dc4
3 changed files with 10 additions and 16 deletions

View file

@ -507,7 +507,7 @@ fun MapView(
val geoPoints = model.nodesWithPosition.map { GeoPoint(it.latitude, it.longitude) }
val box = BoundingBox.fromGeoPoints(geoPoints)
val center = GeoPoint(box.centerLatitude, box.centerLongitude)
val finalZoomLevel = minOf(box.requiredZoomLevel() * 0.8, maxZoomLevel)
val finalZoomLevel = minOf(box.requiredZoomLevel(), maxZoomLevel)
controller.setCenter(center)
controller.setZoom(finalZoomLevel)
} else {

View file

@ -278,7 +278,7 @@ fun BoundingBox.requiredZoomLevel(): Double {
val latLonHeight = topLeft.distanceToAsDouble(GeoPoint(bottomRight.latitude, topLeft.longitude))
val requiredLatZoom = log2(360.0 / (latLonHeight / 111320))
val requiredLonZoom = log2(360.0 / (latLonWidth / 111320))
return maxOf(requiredLatZoom, requiredLonZoom)
return maxOf(requiredLatZoom, requiredLonZoom) * 0.8
}
/**