Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get por latitude e longitude #21

Open
ir4ever opened this issue Sep 17, 2020 · 0 comments
Open

Get por latitude e longitude #21

ir4ever opened this issue Sep 17, 2020 · 0 comments

Comments

@ir4ever
Copy link

ir4ever commented Sep 17, 2020

Estou tentando receber os dados usando latitude e longitude, mas me retorna uma cidade muito longe da minha.
Latitude e longitude testados: -21.1248664,-41.671004
Estou usando a linguagem dart e minha classe eh essa:
class CepViaLatitude {
static Future fetchCep({String lat, String lng}) async {
var headers = {'Authorization': 'Token token=5ead8f2681f26e822b9bfced57463340'};
final response = await http.get('https://www.cepaberto.com/api/v3/nearest?lat='+lat+'&lng='+lng, headers: headers);
if (response.statusCode == 200) {
return CepResult.fromJson(response.body);
} else {
throw Exception('Requisição inválida!'+ response.statusCode.toString());
}
}
}
O resultado está dizendo que estou em Niteroi, mas seria Bom Jesus do Itabapoana que fica a uns 500km de Niteroi.
Não sei se a url está correta mas observando as outras linguagens e exemplos me parece esta correta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant