[core] harden fetching camera for bounds when padding is excessive
This commit is contained in:
committed by
Łukasz Paczos
parent
10114c85bb
commit
419bfbe0eb
@@ -205,8 +205,13 @@ CameraOptions cameraForLatLngs(const std::vector<LatLng>& latLngs, const Transfo
|
||||
scaleY -= (padding.top() + padding.bottom()) / height;
|
||||
minScale = util::min(scaleX, scaleY);
|
||||
}
|
||||
double zoom = transform.getZoom() + util::log2(minScale);
|
||||
zoom = util::clamp(zoom, transform.getState().getMinZoom(), transform.getState().getMaxZoom());
|
||||
|
||||
double zoom = transform.getZoom();
|
||||
if (minScale > 0) {
|
||||
zoom = util::clamp(zoom + util::log2(minScale), transform.getState().getMinZoom(), transform.getState().getMaxZoom());
|
||||
} else {
|
||||
Log::Error(Event::General, "Unable to calculate appropriate zoom level for bounds. Vertical or horizontal padding is greater than map's height or width.");
|
||||
}
|
||||
|
||||
// Calculate the center point of a virtual bounds that is extended in all directions by padding.
|
||||
ScreenCoordinate centerPixel = nePixel + swPixel;
|
||||
|
||||
Reference in New Issue
Block a user