开发者

MonoTouch get location & capture map image like contacts

As the title, I'm confused with how to capture maps with MonoTouch, and how to get the location. As step by:

CLLocationManager locationManager = new CLLocationManager ();
locationManager.UpdatedLocation += UpdatedLocationEvent;
locationManager.Delegate = new MyLocationDelegate ();

locationManager.StartUpdatingLocation ();

    class MyLocationDelegate 开发者_StackOverflow社区: CLLocationManagerDelegate
{
    public MyLocationDelegate () : base()
    {
    }

    public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
    {
        Console.WriteLine ("newLocation  " + newLocation.VerticalAccuracy + "    " + newLocation.HorizontalAccuracy);
        Console.WriteLine ("oldLocation  " + oldLocation.VerticalAccuracy + "    " + oldLocation.HorizontalAccuracy);
    }

    public override void Failed (CLLocationManager manager, NSError error)
    {
        Console.WriteLine ("Failed to find location");
    }
}

It doesn't work. Please help me.


You have not configured the kind of events that you get, you are missing a line like this:

locationManager = new CLLocationManager () {
    DesiredAccuracy = CLLocation.AccuracyBest,
    Delegate = new MyCLLocationManagerDelegate (callback),
    DistanceFilter = 1000f
};
if (CLLocationManager.LocationServicesEnabled)
    locationManager.StartUpdatingLocation ();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜