In the example from react native mapview they have latitudeDelta and longitudeDelta. Is it equal to the height and width? And in what unit? Accoring to their github comment , it says
Distance between the minimum and the maximum latitude/longitude to be displayed.
But that doesn't help me out. I want to know what the user see on the map.
The amount of north-to-south distance (measured in degrees) to display on the map. Unlike longitudinal distances, which vary based on the latitude, one degree of latitude is always approximately 111 kilometers (69 miles).
react-native-maps provides a Map component that uses Apple Maps or Google Maps on iOS and Google Maps on Android. Expo uses react-native-maps at react-community/react-native-maps. No setup required for use within the Expo Go app.
I also came here because I couldn't find any good documentation and Googling didn't help. The following is from my own research:
Only one of either latitudeDelta
or longitudeDelta
is ever used for calculating the size of the map. It takes the larger of the two according to the following formula and ignores the other. This is done to avoid stretching the map.
longitudeDelta/width
and latitudeDelta/height
, compares those 2 computed values, and takes the larger of the two.longitudeDelta
, then the left edge is longitude - longitudeDelta
and the right edge is longitude + longitudeDelta
. The top and bottom are whatever values are needed to fill the height without stretching the map.latitudeDelta
, then the bottom edge is latitude - latitudeDelta
and the top edge is latitude + latitudeDelta
. The left and right are whatever values are needed to fill the width without stretching the map.Here are some examples:
// this uses latitudeDelta because 0.04/300 > 0.05/600 <MapView style={{width: 600, height: 300}} region={{ latitude: 31.776685, longitude: 35.234491, latitudeDelta: 0.04, longitudeDelta: 0.05, }} /> // this uses longitudeDelta because 0.05/600 > 0/myVar when myVar > 0 <MapView style={{width: 600, height: myVar}} region={{ latitude: 40.689220, longitude: -74.044502, latitudeDelta: 0, longitudeDelta: 0.05, }} />
i found this in apple developer guide
The amount of east-to-west distance (measured in degrees) to display for the map region. The number of kilometers spanned by a longitude range varies based on the current latitude. For example, one degree of longitude spans a distance of approximately 111 kilometers (69 miles) at the equator but shrinks to 0 kilometers at the poles.
😀 there have an issue in GitHub too for that library that have been resolved
https://github.com/react-community/react-native-maps/issues/637
this visual explanation also help stackoverflow.com
in this Wikipedia article it shows how to calculate exact value
https://en.wikipedia.org/wiki/Latitude#Length_of_a_degree_of_latitude
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With