Representable / representable

We’re creating maps of communities to fight for fair representation. Add your community to the map today and make your voice heard.
https://representable.org
GNU General Public License v3.0
15 stars 6 forks source link

Safari Compatibility Error - Map Drawing Fails #172

Closed theodormarcu closed 4 years ago

theodormarcu commented 4 years ago

Describe the bug Safari prevents proper map drawing because of a Mapbox API error. This prevents users from seeing the drawing menu.

To Reproduce

  1. Open safari.
  2. Go to "Draw a Community" section.
  3. Press on "Draw Polygon." Check console for errors.

Expected behavior Safari should not fail. Better yet, Safari should fail silently if something happens with the Mapbox API.

k-y-le commented 4 years ago

The 404 errors are occurring because of the mbtiles format census block files, when out of view, are not loaded (apparently due to tippecanoe) -- this seems to be normal, and expected, although I'm not sure why it only happens in safari.

I'm not 100% convinced the 404 errors are related to the fact that the buttons aren't showing up. It seems that the onclick listener for the draw button is never being called. I'm going to keep looking into it and see what i find

For me, I can still draw a community, and it still highlights the census blocks when I do so -- are you getting the same?

k-y-le commented 4 years ago

still trying to explore this.. not totally getting anywhere. based off of this mapbox thread (https://github.com/mapbox/mapbox-gl-js/issues/1800) and the behavior of 404s in general, i dont know that it's possible to suppress these errors? and they will always happen because of the way census blocks are loaded.

but what i don't understand is how they might impact the behavior of the buttons on the map. i've tried exploring the code a bit more and am still gettin ghte same bug

EDIT: so i think the problem may be that the event listener is not bound to the correct element since it isn't available in the DOM upon loading... looking into it

indraneel commented 4 years ago

@k-y-le i got what you got — drawing and census block snapping works, but it looks like the buttons fail to appear. Seems like this function isn't firing in Safari: https://github.com/Representable/representable/blob/be2e894233ccff1d72ffad22d76fb5ef1efe46e7/main/static/main/js/geo.js#L922

edit: didn't see your EDIT, looks like you have identified it already