2009-11-27 7 views
4

저는 iPhone 응용 프로그램의 새로운 사용자입니다. 내 핀을 보여주고 싶었어 MKMapView. 내가 어떻게 해?지도보기에 핀을 넣는 방법은 무엇입니까?

몇 가지 중요한 제안 사항을 알려주십시오. 당신은 점의 좌표를 전달하여 AnnotionDelegate 개체 중 하나를 (인스턴스화해야하는지도 포인트 각각에 대해

@interface AnnotationDelegate : NSObject <MKAnnotation> { 
    CLLocationCoordinate2D coordinate; 
} 

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate; 

- (id) initWithCoordinate:(CLLocationCoordinate2D)coord; 

@end 

@implementation AnnotationDelegate 

@synthesize coordinate; 

- (id) initWithCoordinate:(CLLocationCoordinate2D)coord 
{ 
    coordinate.latitude = coord.latitude; 
    coordinate.longitude = coord.longitude; 
    return self; 
} 

@end 

:

+0

다른 질문을 받아 들여야합니다. 그렇게하면 더 많은 답변을 얻을 수 있습니다. – RedBlueThing

답변

4

당신은 MKAnnotation 프로토콜을 구현하는 대리자를 만들 필요가)와 MKMapView에 추가 :

AnnotationDelegate * annotationDelegate = [[[AnnotationDelegate alloc] initWithCoordinate:coordinate] autorelease]; 
[self._mapView addAnnotation:annotationDelegate]; 
0
if([points retainCount] > 0) 
    { 
    [points release]; 
    points = nil; 
    } 


    if([annotationAry retainCount] > 0) 
    { 
    [annotationAry release]; 
    annotationAry = nil; 
    } 
    points = [[NSMutableArray alloc]init]; 
    annotationAry = [[NSMutableArray alloc]init]; 
    for(int i=0;i<[longitudeary count];i++) 
    { 
    CLLocation* currentLocation1 = [[CLLocation alloc] initWithLatitude:[[latitudeary objectAtIndex:i]doubleValue] longitude:[[longitudeary objectAtIndex:i]doubleValue]]; 

    [points addObject:currentLocation1]; 
    } 


    for(int i=0;i<[points count];i++) 
    { 
    // CREATE THE ANNOTATIONS AND ADD THEM TO THE MAP 
    CSMapAnnotation* annotation = nil; 

    // create the start annotation and add it to the array 
     annotation = [[[CSMapAnnotation alloc] initWithCoordinate:[[points objectAtIndex:i] coordinate] 
          annotationType:CSMapAnnotationTypeImage 
           title:@"123456..." 
           shID:[shIDary objectAtIndex:i] 
           catID:[catIDary objectAtIndex:i] 
          ciggUse:[ciggaretteUSEary objectAtIndex:i] 
          wifiUse:[wifiUSEary objectAtIndex:i] 
          controller:self]autorelease]; 


    [annotationAry addObject:annotation]; 
    } 

    [mapViewmy addAnnotations:[NSArray arrayWithArray:annotationAry]]; 
1
NSString * urlString = nil; 
     urlString = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",12.58, 77.35, [NSString stringWithFormat:@"%@,%@,%@",[detailInfoDict valueForKey:@"address"],[detailInfoDict valueForKey:@"city"],[detailInfoDict valueForKey:@"state"]]]; 
     urlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]] 
관련 문제