KML查看器问题
这是我的第一篇文章,诚然我有点难以理解,但我确实需要一些帮助。
我下载了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
KMLViewer 中的地图变量被声明为 IBOutlet,并连接到 xib 中的 MKMapView。通过重新创建它,新实例将不再连接到 xib 中的实例。
覆盖层可能不会显示,因为:
因此,如果您在分配后添加以下两行+init,它应该再次开始工作:
但是,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:
So if you added the following two lines after the alloc+init, it should start working again:
However, the MKMapView in the xib will still be there underneath the new map instance.