Cannot initiate GPS/Location Services

1706
2
03-05-2012 04:33 PM
JoshuaStevens
New Contributor
I've been following the reference guide for getting started w/ the ArcGIS SDK and adding a map to the view. That's working just fine and was quite easy to do.

When following the steps to display the user's location, nothing occurs. Starting the app does not initiate the 'This app would like use your location..." dialog nor does the blue locator dot appear on the map.

Below is the code I'm working with:

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString* bingMapsKey = @"-- my actual key --";
    AGSBingMapLayer* layer = [[AGSBingMapLayer alloc] initWithAppID:bingMapsKey style:AGSBingMapLayerStyleRoad];
    
    if(layer.loaded){
        NSLog(@"Spatial Reference : %@", layer.spatialReference);
    }
    
    [self.mapView addMapLayer:layer withName:@"Tiled Layer"];
    
    self.mapView.gps.autoPanMode = AGSGPSAutoPanModeDefault;
}

- (void)viewDidUnload
{
    [self setMapView:nil];
    [self setMapView:nil];
    [super viewDidUnload];
    [self.mapView.gps stop];
    // Release any retained subviews of the main view.
}

-(void) mapViewDidLoad:(AGSMapView*)mapView {
  [self.mapView.gps start];
}


I've compared this to the included map view sample, though I can't identify the difference with the [self.mapView.gps start]; option.

It appears the mapViewDidLoad is never happening (if I put in an NSLOG() it never gets output).

Any clues on what I'm missing?

Thanks in advance for taking a look!
0 Kudos
2 Replies
Nicholas-Furness
Esri Regular Contributor
Hi Joshua,

You need to set the map view's layer delegate. Add this line to your viewDidLoad method:

self.mapView.layerDelegate = self;


Edit: Also, see Nimesh's answer below.

That should get you into the mapViewDidLoad: method.

Cheers,

Nick.
0 Kudos
NimeshJarecha
Esri Regular Contributor
Also, you'll have to adopt the AGSMapViewLayerDelegate protocol in your class header.

Regards,
Nimesh
0 Kudos