Language-Mapping / language-map

Front-end codebase for Language Mapping web map
https://languagemap.nyc
MIT License
7 stars 4 forks source link

Resolve (hopefully) web-mercator assertion failure #285

Closed abettermap closed 3 years ago

abettermap commented 3 years ago
abettermap commented 3 years ago

@rperlin-ela hopefully this fixes it. basically whenever there's a "zoom to bounds", be it a neighborhood, county, filtered lang points, or Zoom Home, i have a bit of "padding" set around the extent so that it's not crammed up against the edges of the map and potentially beneath the map controls, logo, etc.

The problem occurs when (somehow) the screen is not large enough to accommodate both the padding and the bounds (e.g. of the polygon), if that makes sense. I still have no idea how users are triggering it, and I was only able to reproduce it by setting the map container to reeeeeally small, and THEN the problem showed up. I'm guessing it's something to do with resolution, like maybe these users have their screen set to enormously large or small, but it's soooo many people that I'm not sure whether such an edge-casey reason applies.

So now the "fix" is that I'm just checking whether the map height and width are larger than 2x the padding (left + right, or top + bottom). If not, I just fall back to NO padding. Not ideal but at least it won't break. I tested the deploy on as small a screen as Chrome Dev Tools would let me make, and no errors. Did the same in prod, w/same size, and our old friend showed up.

Merging!

abettermap commented 3 years ago

as an added preventative measure, i wrapped that whole chunk of code in a try/catch block, which basically "tries" to do the thing, then aborts said thing if something goes wrong.