2013-10-12 4 views
1

내 프로젝트에 OCMapView을 사용하고 있습니다. OCMapView는 Map Kit cluster pinpoints.mkmapview에 선을 그리는 방법

mapkit에 줄을 추가하고 싶습니다. 이

enter image description here

그러나처럼 내 코드는이 일을 : 그것은지도에 선을 오버레이 논리 화 아니다.

enter image description here

는이 코드를 처리합니다.

CLLocationCoordinate2D *coordinates 
    = malloc(sizeof(CLLocationCoordinate2D) * [self.mapView.annotations count]); 
    for (int i=0; i<[self.mapView.annotations count]; i++) { 
     OCMapViewSampleHelpAnnotation * ann=[annodationArray objectAtIndex:i]; 
     coordinates[i]=ann.coordinate; 


    } 
    self.routeLineView=nil; 
self.routeLine = [MKPolyline polylineWithCoordinates:coordinates count:self.mapView.annotations.count]; // 
    free(coordinates); 
    [self.mapView setVisibleMapRect:[self.routeLine boundingMapRect]]; //If you want the route to be visible 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [self.mapView addOverlay:self.routeLine]; 
    }); 

당신은

- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay{ 
    //normally here is circle. 

    if(overlay == self.routeLine) 
    { 
     if(nil == self.routeLineView) 
     { 
      self.routeLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine]; 
      self.routeLineView.fillColor = [UIColor redColor]; 
      self.routeLineView.strokeColor = [UIColor redColor]; 
      self.routeLineView.lineWidth = 3; 

     } 

     return self.routeLineView; 
    } 

    return nil; 


} 

또한 내 프로젝트의 코드를 공유하고 내 오버레이 delagate 방법을 볼 수 있습니다. 이 문제를 어떻게 해결할 수 있습니까?

https://www.dropbox.com/s/q0gtwihtl8o2pom/OCMapView-master.zip

답변

0

그냥 대신 self.mapView.annotations (이 추가 된 모든 주석이다) (이는 사람 볼 수 있습니다) self.mapView.displayedAnnotations를 사용합니다.

관련 문제