Skip to content

Commit

Permalink
bfx: Apply workaround for mapboxgl-js bug
Browse files Browse the repository at this point in the history
Version 1.8.0 of mapboxgl-js does not support a "padding" option
for the .flyTo() function.

Newer versions (up to 1.11.0-beta.1 as of this writing) fix this,
but come with a strange bug:
padding works perfectly initially,
but once a base has been selected for the first deployment,
all subsequent flyTo/fitBounds calls are off-center.

(My suspicion is that it's related to mapbox-gl-js #9477,[0]
in which padding is applied twice...?)

[0]: mapbox/mapbox-gl-js#9477
  • Loading branch information
rlue committed Jun 7, 2020
1 parent 18a0a40 commit 59d7b39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
* update to v1.9.0+ (1.9.0 adds support for a “padding” option on flyTo)
* submit bug report for map fit weirdness from 1.9.0 upgrade
* flyTo point (vs. fitBounds) doesn’t handle the padding option?
* Redo visual design
* Add Reset/Finish buttons
* Disable Finish button when deployments incomplete
* Create guided tour

<!--- deprioritized since we have a workaround! -->
* update to v1.9.0+ (1.9.0 adds support for a “padding” option on flyTo)
* submit bug report for map fit weirdness from 1.9.0 upgrade
2 changes: 1 addition & 1 deletion app/components/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function Map({

switch (true) {
case mapFit instanceof mapboxgl.LngLat:
map.current.flyTo({ center: mapFit, padding, zoom: 9 });
map.current.fitBounds(collectionBounds([mapFit]), { padding, maxZoom: 9 });
break;
case mapFit instanceof mapboxgl.LngLatBounds:
map.current.fitBounds(mapFit, { padding, maxZoom: 9 });
Expand Down

0 comments on commit 59d7b39

Please sign in to comment.