If you, like me, want to open google maps with a fixed width of x kilometeres then Nima's comment is very useful :)
Latitude Deltas for 1km are consistent wherever you are on the earth (1 degree of Latitude is ~110.574km)
But 1km requires a different londitude delta depending on how far you are from the equator. Basically, 1 degree of londitude covers ~111km on the equator, but isnt very far at all in the arctic as this image illustrates:
So I took my learning from other StackOverflow posts and wanted to share my simple conversions for km<-->latitude and km<-->londitude that are as accurate as can be without getting into funky geophysics about the earth not being an exact sphere.
The following should be more than sufficient for most people's needs!:
function radiansToDegrees(angle) {
return angle * (180 / Math.PI);
}
function degreesToRadians(angle) {
return angle * (Math.PI / 180);
}
function latitudesToKM(latitudes) {
return latitudes * 110.574;
}
function kMToLatitudes(km) {
return km / 110.574;
}
function longitudesToKM(longitudes, atLatitude) {
return longitudes * 111.32 * Math.cos(degreesToRadians(atLatitude));
}
function kMToLongitudes(km, atLatitude) {
return km * 0.0089831 / Math.cos(degreesToRadians(atLatitude));
}
So to open a react-native-maps view at point [-0.056809, 51.588491] with width 1km, you just need to do:
<MapView
region={{
latitude: 51.588491,
latitudeDelta: 0.00001, //any number significantly smaller than longitudeDelta
longitude: -0.056809,
longitudeDelta: kMToLongitudes(1.0, 51.588491),
}}
...
All this info is already out there in other StackOverflow posts but i wanted to share this all in one place in case it saves some people some time!