私はiPhone MapViewを初めて使用します。ユーザーがマップを移動すると、iPhoneで表示可能な領域の緯度と経度を取得する必要があります
2550 次
3 に答える
3
MKMapView のプロパティを使用して、マップの中心にあるポイントの座標を取得でき
centerCoordinate.latitude
ますcenterCoordinate.longitude
。
例えば :
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(
map.centerCoordinate.latitude, map.centerCoordinate.longitude);
それは、「ユーザーが地図を移動するときに緯度と経度が必要です」という意味の緯度と経度です。
これがお役に立てば幸いです…</p>
于 2013-05-11T09:21:43.463 に答える
1
これをあなたのAppdelegate.h
CLLocationManager *locationManager;
次に、これらの行をAppdelegate.m (didFinishLaunchingWithOptions)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startMonitoringSignificantLocationChanges];
[locationManager startUpdatingLocation];
これは、デバイスで移動するときにメソッドを呼び出します。
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *currentLocation = [locations lastObject];
NSString *latitude = [NSString stringWithFormat:@"%g", currentLocation.coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%g", currentLocation.coordinate.longitude];
NSMutableArray *temp = [[NSMutableArray alloc] initWithCapacity:0];
[temp addObject:latitude];
[temp addObject:longitude];
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
[def setObject:temp forKey:@"CLocation"];
[temp release];
}
使用はこちらから。
于 2013-05-11T06:16:51.513 に答える