i want to alert the curlat variable in a other function so i can use it in the google maps feature. But i cant get it to work.
var getLocation = {
    init: function () {
        var curlat = "";
        function onSuccess(position) {
            curLat = position.coords.latitude;
        };   
        function onError(error) {
            alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
        }
        navigator.geolocation.getCurrentPosition(onSuccess, onError);
    }
}
var map = {
    init: function () {
        alert(curLat); // alert the cordinate here
        //Google maps API initialisation
        var element = document.getElementById("map");
        //Define the properties of the OSM map to be displayed 
        var map = new google.maps.Map(element, {
            center: new google.maps.LatLng(57, 21),
            zoom: 11,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true,
            mapTypeControl: false,
            streetViewControl: false
        });
        //Define OSM map type pointing at the OpenStreetMap tile server         
        map.mapTypes.set("OSM", new google.maps.ImageMapType({
            getTileUrl: function (coord, zoom) {
                return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
            },
            tileSize: new google.maps.Size(256, 256),
            name: "OpenStreetMap",
            maxZoom: 18
        }));
    }
}
 
     
    