function ensureAndCreateLocator()

in src/windows/GeolocationProxy.js [26:47]


function ensureAndCreateLocator () {
    let deferral;

    const loc = new Windows.Devices.Geolocation.Geolocator();

    if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') {
        deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) {
            if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) {
                return loc;
            }

            return WinJS.Promise.wrapError({
                code: PositionError.PERMISSION_DENIED,
                message: 'Geolocation access has not been allowed by user.'
            });
        });
    } else {
        deferral = WinJS.Promise.wrap(loc);
    }

    return deferral;
}