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
This commit is contained in:
Max Chernin 2018-11-08 04:19:33 -08:00 committed by Michael Diego
parent 16236f9d7e
commit f73e774a45

View File

@ -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