KML查看器问题

发布于 2024-11-06 01:53:34 字数 422 浏览 1 评论 0原文

这是我的第一篇文章,诚然我有点难以理解,但我确实需要一些帮助。

我下载了 Apple 的 KMLViewer 示例来查看地图中的叠加层。让它工作后,作为我的“调查”的一部分,我

map = [[MKMapView alloc] initWithFrame:self.view.frame];

在我知道我也没有的行之后

[super viewDidLoad];

添加了行,但我有另一个项目需要以编程方式创建 MKMapView,我想验证该方法一个更简单、可行的程序。

结果是 KMLViewer 编译并执行时没有错误,但不再显示由 kml 文件创建的叠加层。如果这条线被移除,覆盖层会再次出现。

我缺少什么?

预先感谢您的任何帮助。

This is my first post and I am admittedly over my head, but I do need some help.

I downloaded Apple's KMLViewer example to look at overlays in maps. After getting it to work, as part of my "investigation," I then added the line

map = [[MKMapView alloc] initWithFrame:self.view.frame];

right after the line

[super viewDidLoad];

I know I didn't have too, but I had another project that required programmatically creating a MKMapView and I wanted to verify the approach on a simpler, working program.

The result was the KMLViewer compiled and executed with no errors, but no longer showed the overlays created by the kml files. If the line was removed, the overlays showed up again.

What am I missing?

Thanks in advance for any help.

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

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

发布评论

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

评论(1

秉烛思 2024-11-13 01:53:34

KMLViewer 中的地图变量被声明为 IBOutlet,并连接到 xib 中的 MKMapView。通过重新创建它,新实例将不再连接到 xib 中的实例。

覆盖层可能不会显示,因为:

  • 未设置新实例上的委托(因此不会调用 viewForOverlay 等)
  • 新地图未添加为子视图

因此,如果您在分配后添加以下两行+init,它应该再次开始工作:

map.delegate = self;
[self.view addSubview:map];

但是,xib 中的 MKMapView 仍将位于新地图实例下方。

The map variable in KMLViewer is declared as an IBOutlet and is connected to the MKMapView in the xib. By re-creating it, the new instance is no longer connected to the one in the xib.

The overlays are probably not showing because:

  • the delegate on the new instance is not set (so viewForOverlay, etc. won't get called)
  • the new map isn't added as a subview

So if you added the following two lines after the alloc+init, it should start working again:

map.delegate = self;
[self.view addSubview:map];

However, the MKMapView in the xib will still be there underneath the new map instance.

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