LocationHelper: Move clamp from zoomToFit to QML

The OSM plugin has a different zoom tolerance than what we're hardcoding
here. This fixes the map looking funky from being too zoomed while
trying to fit multiple location points at once.

(cherry picked from commit 15d6287995)
This commit is contained in:
Joshua Goins
2024-09-01 14:23:16 -04:00
parent 47408d536d
commit 1c0a5edd2e
2 changed files with 5 additions and 2 deletions

View File

@@ -40,7 +40,7 @@ float LocationHelper::zoomToFit(const QRectF &r, float mapWidth, float mapHeight
const auto zy = std::log2((mapHeight / (p2.y() - p1.y())));
const auto z = std::min(zx, zy);
return std::clamp(z, 5.0, 18.0);
return z;
}
#include "moc_locationhelper.cpp"

View File

@@ -27,7 +27,10 @@ Kirigami.Page {
let c = LocationHelper.center(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox));
return QtPositioning.coordinate(c.y, c.x);
}
map.zoomLevel: LocationHelper.zoomToFit(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox), mapView.width, mapView.height)
map.zoomLevel: {
const zoom = LocationHelper.zoomToFit(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox), mapView.width, mapView.height)
return Math.min(Math.max(zoom, map.minimumZoomLevel), map.maximumZoomLevel);
}
MapItemView {
Component.onCompleted: mapView.map.addMapItemView(this)