-
-
Save vs0uz4/1e300a3f578aa58ae9c47258b11a80f9 to your computer and use it in GitHub Desktop.
Trecho de código utilizado no Hands-on React-native do DevPleno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
regionFrom = (lat, lon, distance) => { | |
distance = distance/2 | |
const circumference = 40075 | |
const oneDegreeOfLatitudeInMeters = 111.32 * 1000 | |
const angularDistance = distance/circumference | |
const latitudeDelta = distance / oneDegreeOfLatitudeInMeters | |
const longitudeDelta = Math.abs(Math.atan2( | |
Math.sin(angularDistance)*Math.cos(lat), | |
Math.cos(angularDistance) - Math.sin(lat) * Math.sin(lat))) | |
return result = { | |
latitude: lat, | |
longitude: lon, | |
latitudeDelta, | |
longitudeDelta, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment