Search code examples
iphoneobjective-ciosxcode4.3arcgis

mapViewDidLoad method not loaded


New to objective c, and I am using ArcGIS for the map portion. I have a problem where the method mapViewDidLoad is not called/loaded. Here is some part of the code:

.h file

@interface ViewController : UIViewController<AGSMapViewLayerDelegate, AGSMapViewTouchDelegate, AGSMapViewCalloutDelegate>{
AGSMapView *_mapView;
AppDelegate *appDelegate;
...
}

.m file

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.activityView startAnimating];
    self.mapView.touchDelegate = self;
    self.mapView.calloutDelegate = self;
    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    ...
}

- (void)mapViewDidLoad:(AGSMapView *)mapView {

    AGSEnvelope *envelope = [[AGSEnvelope alloc]initWithXmin:29757.610204117
                                                    ymin:40055.0379682464
                                                    xmax:29884.6992302249
                                                    ymax:40236.6028660071
                                        spatialReference:self.mapView.spatialReference];
    [self.mapView zoomToEnvelope:envelope animated:YES];

    self.mapView.callout.width = 195.0f;
    self.mapView.callout.accessoryButtonHidden = YES;

    [self.mapView.gps start];
    [self.mapView centerAtPoint:self.mapView.gps.currentPoint animated:YES];   
    NSLog(@"Location : %@", self.mapView.gps.currentPoint);

    [self.activityView stopAnimating];
    self.activityView.hidden = YES;

}

What is wrong with my code why i doesn't load the mapViewDidLoad method. Thanks in advance.


Solution

  • make sure that mapviewdelegate is connected by right click on mapview and then assign delegate.. enter image description here

    or add [self.mapview setDelegate:self];

    in your case "AGSMapView" mapViewDidLoad: method on AGSMapViewLayerDelegate is invoked after the first layer has been added to the map. At this point, the component is fully functional you can find reference to it in http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/reference/interface_a_g_s_map_view.html

    make self.mapview.layerDelegate = self;