zsawaf
zsawaf

Reputation: 2011

Xamarin.iOS geolocation

I have been browsing the web for a couple of hours to find ways to get the device's geolocation but to no avail.

I could find some documentation for android, but nothing for iOS. Anyone has any ideas or can point me to the right direction?

Upvotes: 1

Views: 1623

Answers (1)

Jason
Jason

Reputation: 89204

The Xamarin.Mobile component has a cross-platform GeoLocation service. It comes with samples.

Xamarin also has a Core Location sample app.

This question has also been asked and answered on Stack Overflow many times.

CLLocationManger lm = new CLLocationManger();
... (Acurray)
... (Other Specs)

lm.LocationsUpdated += delegate(object sender, CLLocationsUpdatedEventArgs e) {
    foreach(CLLocation l in e.Locations) {
        Console.WriteLine(l.Coordinate.Latitude.ToString() + ", " +l.Coordinate.Longitude.ToString());
    }
};

lm.StartUpdatingLocation();

Upvotes: 3

Related Questions