Solved! Go to Solution.
The GPS feed can be quite erratic for the first second or two of polling. The first few values returned may also be nil, which could cause issues if you are feeding them into the map's panning/zooming methods. Many of the apps I have written using GPS and the ArcGIS Runtime SDK have a GPS stabilization polling thread that is called when the GPS is first started and notifies when the GPS has become reasonably stable. The code running on the polling thread looks like this:-(void)observeForGPSStabilization:(AGSLocationDisplay *)locationDisplay; { dispatch_async(gpsStabilizerQueue, ^(void){ BOOL stable = NO; while (!stable) { stable = [self isStabilized:locationDisplay.location.point]; } [self performSelectorOnMainThread:@selector(notifyOfStabilization:) withObject:locationDisplay.location.point waitUntilDone:NO]; }); } -(BOOL)isStabilized:(AGSPoint *)point; { if(point == nil) //if we are not getting a point yet, the GPS has not even started tracking { return NO; } else { if(CurrentDelta(point, lastGPSPoint) < maxStableDelta) //this macro calculates whether we are under an acceptable drift { return YES; } else { lastGPSPoint = point; return NO; } } }
Since you are still on 2.3, you will need to modify that slightly to feed off of an AGSGPS object. The maxStableDelta value is quite high, equivalent to moving at several hundred meters per second. I've found that the initial GPS jumping can sometimes be hundreds of miles per update, or more.
Hi there,
I'm not sure if I did something wrong, but when I called [map.gps start] to locate current location,
my map will sometime zoom in to the lowest scale the map, even though I only called auto pan to current location.
Not sure why it keep doing that 😞
If anyone got a solution, please help.
Edit: Not sure if they are related, but I set enable auto pan mode to AGSPAutoPanModeDefault after
I called [map.gps start]
Thank you,
Tang
Are you using the 10.1.1 version of the SDK? GPS related class/methods have been modified. For eg, AGSGPS class is renamed to AGSLocationDisplay, and [mapView.gps start] to [mapView.locationDisplay startDataSource], and enumerations like AGSPAutoPanModeDefault take the form AGSLocationDisplayAutoPanModeDefault.
Check out here for the changes.
The functionality still remains the same. AGSLocationDisplayAutoPanModeDefault should only zoom to the current location, and not to the center point of the map. AGSLocationDisplayAutoPanModeOff just displays the GPS symbol and doesn't zoom or pan.
Did you try the MapViewDemo sample app that comes with the SDK or the GpsSample? If it doesn't work, can you share the code that you are using?
Thanks,
Suganya
if(!self.mapView.gps.enabled) { [self.mapView.gps start]; } [self.mapView.gps setWonderExtentFactor:0]//re-center map around current position self.mapView.gps.autoPanMode = AGSGPSAutoPanModeDefault;
Hi there,
I'm not sure if I did something wrong, but when I called [map.gps start] to locate current location,
my map will sometime zoom in to the lowest scale the map, even though I only called auto pan to current location.
-(void)observeForGPSStabilization:(AGSLocationDisplay *)locationDisplay; { dispatch_async(gpsStabilizerQueue, ^(void){ BOOL stable = NO; while (!stable) { stable = [self isStabilized:locationDisplay.location.point]; } [self performSelectorOnMainThread:@selector(notifyOfStabilization:) withObject:locationDisplay.location.point waitUntilDone:NO]; }); } -(BOOL)isStabilized:(AGSPoint *)point; { if(point == nil) //if we are not getting a point yet, the GPS has not even started tracking { return NO; } else { if(CurrentDelta(point, lastGPSPoint) < maxStableDelta) //this macro calculates whether we are under an acceptable drift { return YES; } else { lastGPSPoint = point; return NO; } } }
The GPS feed can be quite erratic for the first second or two of polling. The first few values returned may also be nil, which could cause issues if you are feeding them into the map's panning/zooming methods. Many of the apps I have written using GPS and the ArcGIS Runtime SDK have a GPS stabilization polling thread that is called when the GPS is first started and notifies when the GPS has become reasonably stable. The code running on the polling thread looks like this:-(void)observeForGPSStabilization:(AGSLocationDisplay *)locationDisplay; { dispatch_async(gpsStabilizerQueue, ^(void){ BOOL stable = NO; while (!stable) { stable = [self isStabilized:locationDisplay.location.point]; } [self performSelectorOnMainThread:@selector(notifyOfStabilization:) withObject:locationDisplay.location.point waitUntilDone:NO]; }); } -(BOOL)isStabilized:(AGSPoint *)point; { if(point == nil) //if we are not getting a point yet, the GPS has not even started tracking { return NO; } else { if(CurrentDelta(point, lastGPSPoint) < maxStableDelta) //this macro calculates whether we are under an acceptable drift { return YES; } else { lastGPSPoint = point; return NO; } } }
Since you are still on 2.3, you will need to modify that slightly to feed off of an AGSGPS object. The maxStableDelta value is quite high, equivalent to moving at several hundred meters per second. I've found that the initial GPS jumping can sometimes be hundreds of miles per update, or more.