Created
December 7, 2018 22:05
-
-
Save tuliofaria/0e0a3d82364ada7c85d8b2373d59ed4a 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