MonoTouch 获取位置&捕获地图图像(例如联系人)

发布于 2024-11-01 16:39:57 字数 937 浏览 4 评论 0原文

正如标题,我对如何使用 MonoTouch 捕获地图以及如何获取位置感到困惑。一步一步:

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

locationManager.StartUpdatingLocation ();

    class MyLocationDelegate : 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");
    }
}

它不起作用。请帮我。

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 : 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏辞 2024-11-08 16:39:57

您还没有配置获得的事件类型,您缺少这样的行:

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

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 ();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文