GPS에있는 사람을 찾는 프로그램을 추가하려하지만 사람이있는 상태를 값으로 설정합니다. 예 : GPS 자신의 아이폰에서 사람을 찾은 다음 해당 상태를 반환합니다. 캘리포니아 주 변수는 캘리포니아에 문자열로 설정됩니다. 누군가 도움을 주시면 감사하겠습니다!아이폰 GPS에서 주 위치를 찾는 방법?
0
A
답변
2
Core Location을 사용하여 위치를 찾은 다음 MKReverseGeocoder을 사용하여 위치에서 상태를 가져올 수 있습니다.
0
당신이해야 할 일은 현재 좌표를 찾을 CLLocationManager를 설정하는 것입니다. 현재 좌표로 MKReverseGeoCoder를 사용하여 위치를 찾아야합니다. 위의 코드에 대한
- (void)viewDidLoad { // this creates the CCLocationManager that will find your current location CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; [locationManager startUpdatingLocation]; } // this delegate is called when the app successfully finds your current location - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { // this creates a MKReverseGeocoder to find a placemark using the found coordinates MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate]; geoCoder.delegate = self; [geoCoder start]; } // this delegate method is called if an error occurs in locating your current location - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"locationManager:%@ didFailWithError:%@", manager, error); } // this delegate is called when the reverseGeocoder finds a placemark - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { MKPlacemark * myPlacemark = placemark; // with the placemark you can now retrieve the city name NSString *city = [myPlacemark.addressDictionary objectForKey:(NSString*) kABPersonAddressStateKey]; } // this delegate is called when the reversegeocoder fails to find a placemark - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error { NSLog(@"reverseGeocoder:%@ didFailWithError:%@", geocoder, error); }
0
불과 몇 수정 : 당신이 kABPersonAddressStateKey의 컴파일에 문제가있는 경우 kABPersonAddressStateKey 당신에게 국가가 아닌 도시
2를 줄 것이다 사용
1. 프로젝트에 주소록 프레임 워크를 추가 과 같습니다 : 당신의하는 .m 파일
0
에서
#import <AddressBook/AddressBook.h>
가 역 지오 코딩을 사용하여 당신이 필요하고 간단합니다.
CLLocation * 위치 속성을 보유하고있는 클래스가 있다면 내 프로젝트 중 하나에 대해 작성한이 코드 스 니퍼를 사용하면됩니다. 당신이 D에 점점 더 많은 관심을 가질 것입니다
-(void)loadAddress:(void (^)(NSError *error))completion {
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:self.location
completionHandler:^(NSArray *placemarks, NSError *error) {
NSString *address = nil;
if (error) {
self.placemark = nil;
self.address = NSLocalizedString(@"Unknown address.",@"");
}
else {
CLPlacemark * placeMark = [placemarks firstObject];
self.placemark = placeMark;
NSDictionary *d = placeMark.addressDictionary;
address = [(NSArray*)d[@"FormattedAddressLines"] componentsJoinedByString:@" "];
self.address = address;
}
// Call caller
if (completion) completion(error);
}];
}
주 [을 @ "주"] 대신 D보다는 [@ "FormattedAddressLines"]. 역 지오 코딩에는 인터넷 액세스가 필요하며 (웹 서비스로 구현 됨) 볼륨 제한이 있습니다. 대부분 분당 두 개 이상의 통화를 초과해서는 안됩니다. Apple에서 설정 한 용량을 초과하면 오류가 발생합니다. 여러분의 편의를 위해
, 여기에 placeMark.addressDictionary proprerty에 의해 저장된 KV 있습니다 MKReverseGeocoder가 역 지오 코딩을 할 구글을 사용
{
City = Millbrae;
Country = "Etats-Unis";
CountryCode = US;
FormattedAddressLines = (
"I-280 N",
"Half Moon Bay, CA 94019",
"Etats-Unis"
);
Name = "I-280 N";
State = CA;
Street = "I-280 N";
SubAdministrativeArea = "San Mat\U00e9o";
SubLocality = "Bay Area";
Thoroughfare = "I-280 N";
ZIP = 94019;
}
관련 문제
- 1. 프로그램의 위치를 찾는 방법
- 2. 정규식으로 공백 위치를 찾는 방법
- 3. JTextArea에서 커서 위치를 찾는 방법
- 4. 연결이 실패한 위치를 찾는 방법
- 5. UITextView에서 커서의 위치를 찾는 방법
- 6. 리스트에서 위치를 찾는 것,
- 7. MVC에서 뷰를 찾는 위치를 확장하는 방법
- 8. horizontalScrollView에서 가장 오른쪽 위치를 찾는 방법
- 9. android에서 가까운 근거리 위치를 찾는 방법
- 10. ctest를 실행하는 동안 오류가있는 위치를 찾는 방법
- 11. PHP에서 문자열의 문자 위치를 찾는 방법
- 12. 시스템 트레이에서 아이콘의 위치를 찾는 방법
- 13. 내 위치 근처에서 병원 위치를 찾는 방법?
- 14. 창에서 절대 NSView 프레임 위치를 찾는 방법
- 15. PDF에서 텍스트의 x, y 위치를 찾는 방법
- 16. GPS에서 거리를 계산하고 싶습니다.
- 17. Android GPS에서 경로 추가
- 18. Xcode에서 MapKit을 사용하여 위치를 찾는 방법은 무엇입니까?
- 19. 특정 시간에 iPhone GPS에서 현재 위치 보내기
- 20. 을 찾는 중 업데이트 된 파일은 아이폰 프로그래밍에 새로운 아이폰
- 21. 아이폰 주소록이 Google지도에서 주소를 찾는 방법은 무엇입니까?
- 22. windows shell - 스크립트 파일이있는 현재 위치를 찾는 방법?
- 23. PHP를 사용하여 kml 파일 내의 위치를 찾는 방법
- 24. 메모리에서 문자열의 위치를 찾는 방법 (물리적 오프셋이 있음)?
- 25. JavaEE 프로젝트의 경로를 지정하는 방법 또는 위치를 찾는 방법은 무엇입니까?
- 26. VBA. 문자열의 첫 번째 숫자의 위치를 찾는 방법
- 27. 은행, 아이폰에있는 식당과 같은 가장 가까운 위치를 찾는 방법
- 28. 주어진 문서에서 문자열의 위치 또는 위치를 찾는 방법
- 29. 중복 컨트롤 ID (C#)가있는 위치를 찾는 방법
- 30. 웹 페이지에서 안드로이드 사용자의 지리적 위치를 찾는 방법
그냥 경고 - 다른 사람이 여기에 게시 한로 (HTTP ://stackoverflow.com/questions/918423/using-the-google-maps-api-for-reverse-geocoding-lat-long-from-iphone/921165#921165), Google Maps API의 서비스 약관에 위배됩니다. 해당 Google지도를 표시하지 않는 한 데이터를 지오 코딩합니다. (서비스 약관의 섹션 10.12 참조 : http://code.google.com/apis/maps/iphone/terms.html) – delfuego
이러한 방법을 함께 사용하는 방법에 대한 샘플이 있습니까? – Silent