For some reason my "initialLocation" variable is undefined when I make an alert on it, even though I explicitly assign it in the callback function for getCurrentPosition. Variable "initialLocation" is declared globally btw.
Maybe I'm not understanding this concept of closures?
var initialLocation;
if (navigator.geolocation) {
    geoLocationError = true;
    navigator.geolocation.getCurrentPosition(function(position) {
        initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
        getFood();
        }, geoError);
    alert(initialLocation);
} else {
    geoLocationError = false;
    noGeolocation(geoLocationError);
}
 
     
    