From f73e774a4531187308320fed58e7da2a8228e3fc Mon Sep 17 00:00:00 2001 From: Max Chernin <13330924+maxchernin@users.noreply.github.com> Date: Thu, 8 Nov 2018 04:19:33 -0800 Subject: [PATCH] add math abs to avoid negative values when calculating zoom (#655) * add math abs to avoid negative values when calculating zoom * add math.abs with proper styling to pass tests * add math.abs to dx\dy on fitbounds --- src/utils/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 01101a3..ef6874c 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -80,8 +80,8 @@ function fitNwSe(nw, se, width, height) { return null; } - const zoomX = log2(width / GOOGLE_TILE_SIZE / dx); - const zoomY = log2(height / GOOGLE_TILE_SIZE / dy); + const zoomX = log2(width / GOOGLE_TILE_SIZE / Math.abs(dx)); + const zoomY = log2(height / GOOGLE_TILE_SIZE / Math.abs(dy)); const zoom = Math.floor(EPS + Math.min(zoomX, zoomY)); // TODO find center just unproject middle world point