Two things go on. Firstly, the GPS chip does not always return the same place when stopped. A specific GPS location always fluctuates a bit. iOS is making an effort to find that you are standing still and then delivering the same place, but I think this is done to a lesser extent in driving mode.
Secondly, using the convoluted way of storing samples as strings, you go through the %f conversion, which loses accuracy. This can exaggerate any differences between locations. If you use CLLocation objects directly, you are likely to get a better result (and much cleaner code):
[self.points addObject:newLocation]; GMSMutablePath *path = [GMSMutablePath path]; for (CLLocation *col in self.points) { [path addLatitude:col.latitude longitude:col.longitude]; }
Also, make sure you set the correct settings in the CLLocationManager:
theLocationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; theLocationManager.distanceFilter = kCLDistanceFilterNone; theLocationManager.activityType = CLActivityTypeOtherNavigation; theLocationManager.allowsBackgroundLocationUpdates = YES
One more thing. It is also very strange that you change the view in the didUpdateToLocation method:
self.mapContainerView = mapView_;
You should simply use setNeedsDisplay in an existing view after updating the path.
source share