I need a Javascript api that converts a ZIP code typed into latitude and longitude, does anyone know one I can use for free?
I need a Javascript api that converts a ZIP code typed into latitude and longitude, does anyone know one I can use for free?
You can use Google's geocoding . Home Add the Google API
<script src="http://maps.google.com/maps/api/js"></script>
Thenjustpasstheziporaddresstogetthelatitudeandlongitude
varlat='';varlng='';varaddress={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);