how to get the current gps coordinates in xamarin

后端 未结 1 1686
自闭症患者
自闭症患者 2021-01-16 14:48

I would like to get the user\'s current latitude and longitude for ios in xamarin.

I\'ve looked at other posts and as i understand it.

it\'s like:

         


        
相关标签:
1条回答
  • 2021-01-16 15:19

    CLLocationManger is async - it will fire events when the location is updated.

    CLLocationManager lm = new CLLocationManager(); //changed the class name
    ... (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();
    
    0 讨论(0)
提交回复
热议问题