Skip to content

Instantly share code, notes, and snippets.

@tuliofaria
Created December 7, 2018 22:05
Show Gist options
  • Save tuliofaria/0e0a3d82364ada7c85d8b2373d59ed4a to your computer and use it in GitHub Desktop.
Save tuliofaria/0e0a3d82364ada7c85d8b2373d59ed4a to your computer and use it in GitHub Desktop.
Trecho de código utilizado no Hands-on React-native do DevPleno
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