SDK에서 Google MapKit의 확대/축소 수준을 어떻게 설정할 수 있습니까? 예를 들어 뉴욕에 살고 ProjectName-info.plist (URL Types> Item 0> URL Schemes> Item 0)에 4 개의 좌표 위치를 설정 한 다음 my UIViewController 하위 파일 :MapKit에서 줌 레벨 설정 Xcode
#import "GoogleMap.h"
#import "MyAnnotation.h"
@implementation GoogleMap
- (void)viewDidLoad {
[super viewDidLoad];
variable1 = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:@"NewYorkAreas"
ofType:@"plist"]];
double minLat = [[variable1 valueForKeyPath:@"@min.latitude"] doubleValue];
double maxLat = [[variable1 valueForKeyPath:@"@max.latitude"] doubleValue];
double minLon = [[variable1 valueForKeyPath:@"@min.longitude"] doubleValue];
double maxLon = [[variable1 valueForKeyPath:@"@max.longitude"] doubleValue];
MKCoordinateRegion region;
region.center.latitude = (maxLat + minLat)/2.0;
region.center.longitude = (maxLon + minLon)/2.0;
region.span.latitudeDelta = (maxLat - minLat) * 1.05;
region.span.longitudeDelta = (maxLon - minLon) * 1.05;
map.region = region;
for (NSDictionary *newYorkAreasDict in variable1){
MyAnnotation *annotation = [[MyAnnotation alloc] initWithDictionary:newYorkAreasDict];
[map addAnnotation:annotation];
[annotation release];
}
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
if (map.userLocation == annotation){
return nil;
}
NSString *identifier = @"MY_IDENTIFIER";
MKAnnotationView *annotationView = [map dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil){
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:identifier]
autorelease];
annotationView.image = [UIImage imageNamed:@"logo.png"];
annotationView.canShowCallout = YES;
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
return annotationView;
}
그래서 이것은 내가 실행하고 응용 프로그램을 디버깅 할 때 완벽하게 작동 내 코드에서 지금은 모두, 그리고 나에게 내가 좋은 줌 설정 4 개 영역의 위치를 보여줍니다 수준,하지만 지금은 단 1 지역 설정하려는, 그래서 그것을 실행 만 나에게 한 지역을주는 때 다른 세 영역을 지울 때, 줌 레벨은지도에 가까운 것 같다
그래서 코드가 수정되면 (누군가가 줌 레벨에 대한 코드를 수정하는 데 도움이되었다고 가정 할 때) 다음에 실행할 때 "Google지도에서 찾기"를 클릭하면 내 Google지도 오프닝 페이지 줌 레벨이 다음과 같이 보입니다. 그럼 Google지도를 열 때이 줌 레벨을 고칠 수 있도록 도와주세요. 감사합니다.
헤이 덕분에, 그것은 나에게로부터 참조 "_CLLocationCoordinate2DMake", 준 - : 신분증 1 개 종료 상태를 반환 을 [GoogleMap으로의 viewDidLoad] GoogleMap.o에서 심볼 (들) collect2 찾을 수 없습니다 혹시이 오류로 저를 도울 수 있습니까? thanks – PatrickGamboa
해당 기능에 대한 핵심 위치 프레임 워크가 필요합니다. 이를 위해 프레임 워크를 포함하고 싶지 않다면'CLLocationCoordinate2Make ((maxLat + minLat)/2.0, (maxLon + minLon)/2.0)'을'(CLLocationCoordinate2D) {(maxLat + minLat)/2.0, (maxLon + minLon)/2.0}'로 설정합니다. – Anomie
와우, 정말 고마워! 실제로 작동한다! 이제 좀 더 많은 것을 추가 할 수 있습니다! 그런데 사용자가 특정 지역에있을 때 또 다른 질문이 있습니다. Google 버튼을 눌러 Google 페이지를 열면 사용자의 현재 위치와 사업장 사이의 경로가 표시되기를 원합니다. 네가 그걸 도와 줄 수 있다면? 다시 한 번 감사드립니다! – PatrickGamboa