Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Can't get location

$
0
0

Hi,

I'm using Xamarin.Mobile to get the curernt location for the device. I have read the it does not work in the simulator.
Now I have testet it on a device (IOS 9.1)

But with no luck.
The GetPositionAsync never returns.

`public async Task GetCurrentLocation()
{
var locator = new Geolocator { DesiredAccuracy = 50 };
var cancelSource = new CancellationTokenSource();
var location = GeoLocation.Undefined;

        await locator.GetPositionAsync(1000, cancelSource.Token).ContinueWith(
            t => location = t.IsCompleted 
                ? new GeoLocation(t.Result.Latitude, t.Result.Longitude) 
                : GeoLocation.Undefined, 
            cancelSource.Token);

        return location;
    }`

Anyone that knows what to do?

Br Morten


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>