lucassouza16 / expo-location

1 stars 0 forks source link

Does not return the complete address anymore #1

Open ranierishi opened 3 years ago

ranierishi commented 3 years ago

Changed to your package and now i finally get the city but cant get the full address anymore, any idea why?

useEffect(() => {
    ;(async () => {
      const { status } = await Location.requestPermissionsAsync()
      if (status !== 'granted') {
        setErrorMsg('Permission to access location was denied')
        return
      }

      const location = await Location.getCurrentPositionAsync({
        enableHighAccuracy: true,
        accuracy: Location.Accuracy.BestForNavigation,
      })
      setLocation(location)
      const latLong = {
        latitude: location.coords.latitude,
        longitude: location.coords.longitude,
      }
      const address = await Location.reverseGeocodeAsync(latLong)

      console.log('Endereço', address)
    })()
  }, [])

Print:

Endereço Array [
  Object {
    "city": "Belo Horizonte",
    "country": "Brazil",
    "isoCountryCode": "BR",
    "region": "Minas Gerais",
  },
]

Original Expo Location output:

Endereço Array [
  Object {
    "city": null,
    "country": "Brazil",
    "isoCountryCode": "BR",
    "name": "470",
    "postalCode": "31540-540",
    "region": "Minas Gerais",
    "street": "Rua Olávo Bilac",
  },
]
lucassouza16 commented 3 years ago

Changed to your package and now i finally get the city but cant get the full address anymore, any idea why?

useEffect(() => {
    ;(async () => {
      const { status } = await Location.requestPermissionsAsync()
      if (status !== 'granted') {
        setErrorMsg('Permission to access location was denied')
        return
      }

      const location = await Location.getCurrentPositionAsync({
        enableHighAccuracy: true,
        accuracy: Location.Accuracy.BestForNavigation,
      })
      setLocation(location)
      const latLong = {
        latitude: location.coords.latitude,
        longitude: location.coords.longitude,
      }
      const address = await Location.reverseGeocodeAsync(latLong)

      console.log('Endereço', address)
    })()
  }, [])

Print:

Endereço Array [
  Object {
    "city": "Belo Horizonte",
    "country": "Brazil",
    "isoCountryCode": "BR",
    "region": "Minas Gerais",
  },
]

Original Expo Location output:

Endereço Array [
  Object {
    "city": null,
    "country": "Brazil",
    "isoCountryCode": "BR",
    "name": "470",
    "postalCode": "31540-540",
    "region": "Minas Gerais",
    "street": "Rua Olávo Bilac",
  },
]

Unfortunately this is a limitation of the BigDataCloud api that I replaced by the one the expo uses, it does not return the address data, but soon I will see alternatives to update this fork and provide the address too.

lucassouza16 commented 3 years ago

Mudei para o seu pacote e agora finalmente consegui a cidade, mas não consigo mais receber o endereço completo, alguma ideia do porquê?

useEffect(() => {
    ;(async () => {
      const { status } = await Location.requestPermissionsAsync()
      if (status !== 'granted') {
        setErrorMsg('Permission to access location was denied')
        return
      }

      const location = await Location.getCurrentPositionAsync({
        enableHighAccuracy: true,
        accuracy: Location.Accuracy.BestForNavigation,
      })
      setLocation(location)
      const latLong = {
        latitude: location.coords.latitude,
        longitude: location.coords.longitude,
      }
      const address = await Location.reverseGeocodeAsync(latLong)

      console.log('Endereço', address)
    })()
  }, [])

Impressão:

Endereço Array [
  Object {
    "city": "Belo Horizonte",
    "country": "Brazil",
    "isoCountryCode": "BR",
    "region": "Minas Gerais",
  },
]

Resultado do local original da Expo:

Endereço Array [
  Object {
    "city": null,
    "country": "Brazil",
    "isoCountryCode": "BR",
    "name": "470",
    "postalCode": "31540-540",
    "region": "Minas Gerais",
    "street": "Rua Olávo Bilac",
  },
]

Infelizmente, essa é uma limitação da API BigDataCloud que substituí pela que a expo usa, ela não retorna os dados de endereço, mas logo verei alternativas para atualizar este fork e fornecer o endereço também.

Changed to your package and now i finally get the city but cant get the full address anymore, any idea why?

useEffect(() => {
    ;(async () => {
      const { status } = await Location.requestPermissionsAsync()
      if (status !== 'granted') {
        setErrorMsg('Permission to access location was denied')
        return
      }

      const location = await Location.getCurrentPositionAsync({
        enableHighAccuracy: true,
        accuracy: Location.Accuracy.BestForNavigation,
      })
      setLocation(location)
      const latLong = {
        latitude: location.coords.latitude,
        longitude: location.coords.longitude,
      }
      const address = await Location.reverseGeocodeAsync(latLong)

      console.log('Endereço', address)
    })()
  }, [])

Print:

Endereço Array [
  Object {
    "city": "Belo Horizonte",
    "country": "Brazil",
    "isoCountryCode": "BR",
    "region": "Minas Gerais",
  },
]

Original Expo Location output:

Endereço Array [
  Object {
    "city": null,
    "country": "Brazil",
    "isoCountryCode": "BR",
    "name": "470",
    "postalCode": "31540-540",
    "region": "Minas Gerais",
    "street": "Rua Olávo Bilac",
  },
]

Unfortunately this is a limitation of the BigDataCloud api that I replaced by the one the expo uses, it does not return the address data, but soon I will see alternatives to update this fork and provide the address too.

But if you configure a Google Maps api key, I believe that the problem will be solved without the need for a fork, if it doesn't work, can you let me know?

ranierishi commented 3 years ago

Of course, i'm waiting the Google API key from from the project leader and i just decided to try if i could do this without it, but unfortunately didn't had good progress, when they sent me the apiKey i'll let you know