Skip to content

Commit f73e774

Browse files
maxcherninitsmichaeldiego
authored andcommitted
add math abs to avoid negative values when calculating zoom (google-map-react#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
1 parent 16236f9 commit f73e774

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ function fitNwSe(nw, se, width, height) {
8080
return null;
8181
}
8282

83-
const zoomX = log2(width / GOOGLE_TILE_SIZE / dx);
84-
const zoomY = log2(height / GOOGLE_TILE_SIZE / dy);
83+
const zoomX = log2(width / GOOGLE_TILE_SIZE / Math.abs(dx));
84+
const zoomY = log2(height / GOOGLE_TILE_SIZE / Math.abs(dy));
8585
const zoom = Math.floor(EPS + Math.min(zoomX, zoomY));
8686

8787
// TODO find center just unproject middle world point

0 commit comments

Comments
 (0)