react-mapbox-gl icon indicating copy to clipboard operation
react-mapbox-gl copied to clipboard

ScaleControl display incorrect values at low zoom levels

Open confusingstraw opened this issue 5 years ago • 4 comments

The React version of the ScaleControl uses incorrect scale values at lower zoom levels (when the full map is entirely in the viewport). It correctly scales up to the 200km value range, but then begins to bounce between 50 and 10km when zooming out further.

When I switched to using the built-in mapboxgl.ScaleControl the issue went away, and upon looking at the source code it seems this library uses a slightly different method for calculating the distances for the scales. It appears at first glance to be caused by how this library decides upon the top-left and top-right positions, which will begin to scale the opposite way when the map is fully zoomed out (at least it looks that way). The mapboxgl.ScaleControl implementation seems to use the map.unproject function to determine the top-left and top-right positions.

mapboxgl.ScaleControl scale calculation: scale_control.js react-mapbox-gl.ScaleControl scale calculation: scale-control.tsx

confusingstraw avatar Apr 23 '19 16:04 confusingstraw

I noticed this issue as well, can be seen on the all-shapes demo here when fully zooming out. Screenshot 2019-08-12 at 11 41 23

raphael-leger avatar Aug 12 '19 09:08 raphael-leger

I noticed this issue as well

callmeYe avatar May 07 '20 06:05 callmeYe

+1

guiferrpereira avatar Feb 11 '21 10:02 guiferrpereira

+1

sraisty1c avatar Jul 16 '21 18:07 sraisty1c