making a cordova geolocation function to return position
<p>I looked at examples on Cordova Geolocation and I am having trouble figuring out how to return the position from its function so I can call it several times from different locations.</p>

<p>Here is an example of getting the position:</p>

<pre><code>    var onSuccess = function (position) {
        alert('Latitude: ' + position.coords.latitude + '\n' +
            'Longitude: ' + position.coords.longitude + '\n' +
            'Altitude: ' + position.coords.altitude + '\n' +
            'Accuracy: ' + position.coords.accuracy + '\n' +
            'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
            'Heading: ' + position.coords.heading + '\n' +
            'Speed: ' + position.coords.speed + '\n' +
            'Timestamp: ' + position.timestamp + '\n');
    };

    function onError (error) {
        alert('code: ' + error.code + '\n' +
            'message: ' + error.message + '\n');
    }

    navigator.geolocation.getCurrentPosition(onSuccess, onError);
</code></pre>

<p>So I want to be able to call a function and have it return the position object, what its getting from 'onSuccess'</p>