jfbomber

App Crashing when setting AGSMapViewLayerDelegate

Discussion created by jfbomber on May 20, 2012
Latest reply on May 21, 2012 by njarecha-esristaff
I am probably missing somethings but when I set the AGSMapViewLayerDelegate the app crashes.

Here is my code...


// MapViewController.h
#import <ArcGIS/ArcGIS.h>

@interface MapViewController : UIViewController <AGSMapViewLayerDelegate>
{
    AGSMapView *_mapView;
    
}

@end

// MapViewController.m
- (id)init
{
    self = [super init];
    if (self) {
        _mapView = [[AGSMapView alloc]  initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
        //_mapView.layer.delegate = self;
        NSMutableArray *layers =[[NSMutableArray alloc] init];
        
        
        NSURL *tileUrl = [NSURL URLWithString:@"http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"];
        AGSTiledMapServiceLayer *tiledLayer = [[AGSTiledMapServiceLayer alloc] initWithURL:tileUrl]; 
        UIView<AGSLayerView>* tileLyrView = [_mapView addMapLayer:tiledLayer withName:@"Tiled Layer"];
        [layers addObject:tileLyrView];
        
        NSURL* dynamicUrl = [NSURL URLWithString: @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"];
        AGSDynamicMapServiceLayer* dynamicLayer = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL: dynamicUrl];
        UIView<AGSLayerView>* dynamicLyrView = [_mapView addMapLayer:dynamicLayer withName:@"Dynamic Layer"];
        [layers addObject:dynamicLyrView];
        
        // Not using yet
        AGSGraphicsLayer *graphicsLayer = [AGSGraphicsLayer graphicsLayer];
        UIView<AGSLayerView>* graphicLyrView = [_mapView addMapLayer:graphicsLayer withName:@"Graphics Layer"];
        [graphicLyrView setDrawDuringPanning:YES];
        [layers addObject:graphicLyrView];
   
        [self setView:_mapView];
    }
    
    return self;
}


- (void)mapViewDidLoad:(AGSMapView *)mapView {
    // Never fires or crashes before it fires, not sure which one
    NSLog(@"%@", @"mapViewDidLoad");
}




I don't use XIB's, just personal preference.

Outcomes