Map randomly zoom in when called [map.gps start]

871
4
Jump to solution
04-03-2013 07:27 PM
TangWorawitphinyo
New Contributor II
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
0 Kudos
1 Solution

Accepted Solutions
TangWorawitphinyo
New Contributor II
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.



Ah, this make sense. I'll give it s shot.

Thank you very much!
Tang

View solution in original post

0 Kudos
4 Replies
SuganyaBaskaran1
Esri Contributor
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
0 Kudos
TangWorawitphinyo
New Contributor II
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


Hi Suganya,

I'm still using the good old 2.3 version of the SDK <.< since we just don't have time to migrate the app to support 10.1.1 yet.

Basically, my map app got a navigation button that can set the GPS's navigation mode to AGSGPSAutoPanModeDefault, which user
can turn on or off.

I just called the code:
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;


The navigation mode work fine and the map re-center itself around user's current position correctly.
But sometime, the map just randomly decided that it's needed to zoom in to user's current position for no reason -_-
Which is weird, since it's should just pan and not zoom in..

Thank you,
Tang
0 Kudos
DanaMaher
Occasional Contributor
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.



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.
0 Kudos
TangWorawitphinyo
New Contributor II
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.



Ah, this make sense. I'll give it s shot.

Thank you very much!
Tang
0 Kudos