2011-03-23 15 views
0

안녕하세요, iPhone 프로젝트에서 MapKit을 사용하여 Google지도를 만들고지도에서 회사 위치를 지정했습니다. 이제 내 Google지도가 사용자 위치와 회사 위치 사이의 경로를 그려 볼 작은 기능을 추가하고 싶습니다. 지금까지 내가Xcode에서 Google MapKit의 사용자 위치와 지정된 위치 간의 경로를 그립니다.

#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; 
} 

그래서 지금, 나는 사용자의 위치를 ​​구현하고 사용자의 위치와 내 회사 간의 경로를 플롯 할 내 회사의 위치를 ​​지정하는 데 사용되는 코드입니다,하지만 난 아무 단서 방법이 없습니다 그것을 코딩하기 위해 누군가가 나를 도울 수 있기를 바랍니다. 감사합니다!

답변

0

경로를 GPS 좌표로 가져와야하는 한 가지 방법은 MKOverlayView를 사용할 수 있다는 것입니다.

체크 this 자세한 내용은

관련 문제