I´m new to StackOverflow, so if I make a mistake, please be lenient with me.
I have a problem. When I am trying to access to a variable from another function, it results "null".
function initAutocomplete() {
var latitude = 0;
var longitude = 0;
var geocoder = new google.maps.Geocoder();
var address = document.getElementById("geocode").value;
geocoder.geocode({ 'address': address },
function getCoordinates(results, status) {
//if (status == google.maps.GeocoderStatus.OK) {
latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
}
//}
);
var uluru = {lat: latitude,
lng: longitude};
var map = new google.maps.Map
(document.getElementById('map'),
{
center: uluru,
zoom: 17,
mapTypeId: 'roadmap'
});
}