File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,21 @@ export const useMapbox = () => {
35
35
const baseLongOffset = 0.08 ;
36
36
const longitudeOffset = baseLongOffset * Math . pow ( 2 , 11 - currentZoom ) ;
37
37
38
- // calculates latitude offset for mobile according to zoom level and takes screen height into account
39
- const baseLatOffset = 0.05 ;
38
+ // calculates latitude offset for mobile according to zoom level and screen height
39
+ const baseLatOffset = 0.065 ;
40
40
const screenHeight = window . innerHeight ;
41
- const referenceHeight = 800 ;
42
- const screenHeightFactor = screenHeight / referenceHeight ;
43
- const latitudeOffset =
44
- baseLatOffset * Math . pow ( 2 , 11 - currentZoom ) * screenHeightFactor ;
41
+
42
+ function calculateLatOffset ( screenHeight ) {
43
+ const baseHeight = 550 ;
44
+ const rate = 0.006 / 50 ; // approximately 0.006 deg per 50 pixels
45
+ return 0.034 + ( screenHeight - baseHeight ) * rate ;
46
+ }
47
+
48
+ const heightOffsetFactor = ! screenHeight
49
+ ? baseLatOffset
50
+ : calculateLatOffset ( screenHeight ) ;
51
+
52
+ const latitudeOffset = heightOffsetFactor * Math . pow ( 2 , 11 - currentZoom ) ;
45
53
46
54
mapbox . default . flyTo ( {
47
55
center : [
You can’t perform that action at this time.
0 commit comments