小编Kat*_*ine的帖子

MKMapView和addOverlay - 从kml解析叠加层

我正在尝试为简单的iPhone应用程序制作地图叠加层.问题是,即使应用程序没有错误,折线也不会显示在地图上.控制台说[overlay lastObject]实际上是MKPolyline.有人可能会看到我在这里做错了什么...我是iPhone应用程序开发的新手?

这是我的mapView控制器的相关代码:

- (void)viewDidLoad {   
    [super viewDidLoad];    

    CGRect mapFrame = CGRectMake(0.0f, 31.0f, 320.0f, 370.0f);  
    mapView = [[MKMapView alloc] initWithFrame:mapFrame];

    MKCoordinateRegion region;
    MKCoordinateSpan span;
        span.latitudeDelta=.02;
        span.longitudeDelta=.02;

    CLLocationCoordinate2D location;
        location.latitude = 29.43421;
        location.longitude = -98.48436; 

        region.span=span;
        region.center=location; 

    NSURL *url = [NSURL URLWithString:@"They asked me not to post this... It is a valid KML file though"];
    kml = [[KMLParser parseKMLAtURL:url] retain];

    // Add all of the MKOverlay objects parsed from the KML file to the map.
    NSArray *overlay = [kml overlays];      
    NSLog(@"TEST: …
Run Code Online (Sandbox Code Playgroud)

iphone overlay objective-c mkmapview

2
推荐指数
1
解决办法
3166
查看次数

标签 统计

iphone ×1

mkmapview ×1

objective-c ×1

overlay ×1