次のviewdidloadメソッドと場所へのdidupdateを持つ単純なマップビューがあります。
- (void)viewDidLoad {
NSLog(@"in view did load");
[super viewDidLoad];
self.mapView.showsUserLocation = YES;
self.put_url = nil;
locationManager = [[CLLocationManager alloc] init];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager setDelegate:self];
noUpdates = 0;
[locationManager startUpdatingLocation];
self.availableParking = [[NSMutableArray alloc] init];
//self.availableParking = nil;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"in didupdatetolocatoin");
if([newLocation horizontalAccuracy] < 100 && [newLocation horizontalAccuracy] > 0) {
// Add annotation to map
DDAnnotation *annotation = [[DDAnnotation alloc] initWithCoordinate:newLocation.coordinate title:@"Park Here?"];
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 0.05;
span.longitudeDelta = 0.05;
region.span = span;
region.center = newLocation.coordinate;
self.mapView.region = region;
NSLog(@"in didupdatetolocation");
noUpdates++;
NSLog(@"IN UPDATELOCATION NOUPDATES = %d",noUpdates);
if (noUpdates == 1) {
[self.mapView addAnnotation:annotation];
NSLog(@"ADDED ANNOTATION IN didUpdateToLocation!!");
[locationManager stopUpdatingLocation];
[self.settingsViewController setState:self.mapView.userLocation.subtitle andCity:@"fuckface"];
NSLog(@"STOPPED UPDATING LOCATION");
UpdateLocation *updatedLocation = [[[UpdateLocation alloc] initWithUserid:@"fuckface" andCoordinate:newLocation.coordinate withMapViewController:self]
autorelease];
NSLog(@"Lat = %f, Long = %f",newLocation.coordinate.latitude,newLocation.coordinate.longitude);
//[NSThread detachNewThreadSelector:@selector(getLocations) toTarget:self withObject:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(sendUpdate)
name:@"NoteFromOne"
object:updatedLocation];
}
// We only update location once, and let users to do the rest of the changes by dragging annotation to place they want
} else {
NSLog(@"Accuracy not good enough %lf", [newLocation horizontalAccuracy]);
}
}
ワイヤレス ネットワークに接続すると、問題なくズームインし、現在の場所に注釈ピンをドロップできます。3G ネットワーク上では、ピンをズームまたはドロップすることはありません。理由についてのアイデアはありますか?前もって感謝します。
ここにいくつかのスクリーンショットがあります:
3G の場合: 代替テキスト http://www.freeimagehosting.net/uploads/fe7fcbb2ea.jpg
Wi-Fi あり: 代替テキスト http://www.freeimagehosting.net/uploads/6b653e60a7.jpg