Select to view content in your preferred language

proper way of using agsgps ????

870
1
10-27-2010 01:25 AM
HarikantJammi
Emerging Contributor
I have a gps button in my app which is used to toggle on/off the gps services.
I am using the following code to toggle gps services.
The method below is called when the button is touched

-(void) startGPS {
self.mapView.gps.autoPan = YES ;
if ((self.mapView.gps.enabled)) {
 
  [self.mapView.gps stop];
  [self.gpsButton setImage:[UIImage imageNamed:@"gps_off.png"] forState:UIControlStateNormal] ;
 
}
else if(!(self.mapView.gps.enabled))
{
   [self.mapView.gps start];
   [self.gpsButton setImage:[UIImage imageNamed:@"gps_on.png"] forState:UIControlStateNormal]  ;
}


}

This code works fine when location services are turned ON.
Now in iOS 4 , if location services are turned off only for that particular app keeping the global location settings ON then also my buttons are toggling to GPS ON state.

Has anyone observed this problem ?? Is there a workaround for this. Ideally , I would like a sample code to use AGSGPS in a proper way.

Regards,
Harikant Jammi
0 Kudos
1 Reply
DiveshGoyal
Esri Regular Contributor
Harikant,

The self.mapView.gps.enabled property does not indicate whether location services are enabled/disabled for the application, or for that matter, the device.

The property only indicates whether the map is using the location services.

To find out whether location services are available for your app to use, you will need use the CoreLocation framework in iOS.

_
Divesh
(PS : Also take a look at Displaying location on the map)
0 Kudos