Đối với có được thông tin chi tiết bao gồm địa chỉ của POI Tôi nghĩ bạn có thể làm điều này theo hai bước:
Lấy toạ độ POI của bạn
Chuyển đổi họ cho lấy thông tin địa chỉ; xem ví dụ này đẹp:
CLGeocoder *ceo = [[CLGeocoder alloc]init];
CLLocation *loc = [[CLLocation alloc]initWithLatitude:32.00 longitude:21.322]; //insert your coordinates
[ceo reverseGeocodeLocation:loc
completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"placemark %@",placemark);
//String to hold address
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSLog(@"addressDictionary %@", placemark.addressDictionary);
NSLog(@"placemark %@",placemark.region);
NSLog(@"placemark %@",placemark.country); // Give Country Name
NSLog(@"placemark %@",placemark.locality); // Extract the city name
NSLog(@"location %@",placemark.name);
NSLog(@"location %@",placemark.ocean);
NSLog(@"location %@",placemark.postalCode);
NSLog(@"location %@",placemark.subLocality);
NSLog(@"location %@",placemark.location);
//Print the location to console
NSLog(@"I am currently at %@",locatedAt);
}
else {
NSLog(@"Could not locate");
}
];
Nếu bạn cần trung tâm trên một khu vực bản đồ của bạn bạn có thể làm điều đó như thế này:
- (void)gotoLocation
{
MKCoordinateRegion newRegion;
newRegion.center.latitude = NY_LATITUDE;
newRegion.center.longitude = NY_LONGTITUDE;
newRegion.span.latitudeDelta = 0.5f;
newRegion.span.longitudeDelta = 0.5f;
[self.myMapView setRegion:newRegion animated:YES];
}
Tôi hy vọng những ví dụ mã có thể giúp bạn :)
Để tìm hiểu thêm về MKMapViewClass (Tôi khuyên bạn nên) kiểm tra Apple Documentation hoặc this beatiful example on how to manage POI with Apple Maps.
Nguồn
2015-06-08 13:23:04