Why I can't get the coordinates with this code ?
The error is : ReferenceError: Can't find variable: card_Latitude
.
I took the code from here: How to get longitude and latitude of a city/country inputted through an input box?
I do not understand why.
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var card_FullAddress = "Canada";
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': card_FullAddress
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var card_Latitude = results[0].geometry.location.lat();
var card_Longitude = results[0].geometry.location.lng();
} else {
var card_Latitude = "ERR";
var card_Longitude = "ERR";
}
});
console.log(card_Latitude);
console.log(card_Longitude);
</script>