6
I need a Javascript api that converts a typed zip code to latitude and longitude, someone knows one I can use for free?
6
I need a Javascript api that converts a typed zip code to latitude and longitude, someone knows one I can use for free?
12
You can use the geocoding of the google api.
Add the Google API
<script src="http://maps.google.com/maps/api/js"></script>
Then just pass the zip code or address to get the latitude and longitude
var lat = '';
var lng = '';
var address = {cep} or {endereço};
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
lat = results[0].geometry.location.lat();
lng = results[0].geometry.location.lng();
} else {
alert("Não foi possivel obter localização: " + status);
}
});
alert('Latitude: ' + lat + ' Logitude: ' + lng);
Now in 2018 that service is paid for. Someone still uses?
5
15 de April de 2019
Access the URL below:
https://maps.googleapis.com/maps/api/geocode/json?address=SEU_CEP&key=SUA_API_KEY
It will return a JSON containing the full address and latitude and longitude.
For this URL to work, you need to have an account on Google Developers Console and this account needs to have a registered credit card. The amount is approximately $7.00 per 1,000 requests.
Your API_KEY must have enabled Maps Javascript API and Geocode API
Browser other questions tagged javascript google-maps
You are not signed in. Login or sign up in order to post.
Do you want to do this conversion so you can search for the position on google maps? If so, it would not be easier to search the maps directly by the zip code?
– Fleuquer Lima
have tried this, but he does not recognize the zip code to add a marker
– Pedro Freitas
Hence the API code changes, has a specific ZIP code. Use Google’s own guide for this link, type the zip code and it will generate an example code, just need to have the google key to use.
– Fleuquer Lima