问题
I did a .gpx file to simulate a route on IOS simulator, now i wanna simulate the horizontal accuracy how I can do this?
as follow is an excerpt of my .gpx file:
<?xml version="1.0"?>
<gpx>
<wpt lat="-23.772830" lon="-46.689820"/> //how add horizontal accuracy 7 meters for example
<wpt lat="-23.774450" lon="-46.692570"/> //and here horizontal accuracy of 2 metters for example
<wpt lat="-23.773450" lon="-46.693530"/> //and here 19 meters
</gpx>
if I run all gps points return horizontal accuracy of 5 meters, I can change this otherwise.
回答1:
I did this with a method call from the viewController (mine is a button, but obviously you could use a gestureRecognizer or whatever).
I have my viewController set as the LocationManagerDelegate, but you can put in the delegate you're using instead of "self"
- (IBAction)simulateAccuracy:(id)sender {
CLLocationCoordinate2D newCoor = CLLocationCoordinate2DMake(someLat, someLng);
CLLocation *newLoc = [[CLLocation alloc] initWithCoordinate:newCoor altitude:someAlt
horizontalAccuracy:TheAccuracyYouWantToTest verticalAccuracy:ditto timestamp:nil];
NSArray *newLocation = [[NSArray alloc] initWithObjects:newLoc,nil];
[self locationManager:myLocationManager didUpdateLocations:newLocation];
}
来源:https://stackoverflow.com/questions/13146553/simulate-low-and-hight-gps-accuracy