[ios, osx] Better zoom level–altitude conversion

Greatly simplified conversions between zoom level and altitude. Adjusted field of view to more closely match MapKit. Conversions are now well within the same order of magnitude as MapKit at all latitudes.

Fixes #2266.
This commit is contained in:
Minh Nguyễn
2015-12-20 01:22:52 -08:00
committed by Minh Nguyễn
parent cafe591d2a
commit d668c0fa84
6 changed files with 71 additions and 185 deletions

View File

@@ -364,6 +364,8 @@ void Transform::flyTo(const CameraOptions &options) {
state.latY(latLng.latitude),
};
zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom());
// Minimize rotation by taking the shorter path around the circle.
double normalizedAngle = _normalizeAngle(angle, state.angle);
state.angle = _normalizeAngle(state.angle, normalizedAngle);
@@ -395,6 +397,7 @@ void Transform::flyTo(const CameraOptions &options) {
double rho = 1.42;
if (flyOptions.minZoom) {
double minZoom = util::min(*flyOptions.minZoom, startZoom, zoom);
minZoom = util::clamp(minZoom, state.getMinZoom(), state.getMaxZoom());
/// w<sub>m</sub>: Maximum visible span, measured in pixels with respect
/// to the initial scale.
double wMax = w0 / state.zoomScale(minZoom - startZoom);