2013-02-15 1 views
0

mapbox sdk를 사용하여 맵 응용 프로그램을 구현했습니다. 마커와 경로를 함께 보여줄 필요가 있습니다.하지만 Google에서이 방법을 사용하는 것은 아닙니다. RMShape 및 RMMapView로 경로 지정

지금까지 내가했던

...

- (RMMapLayer *)mapView:(RMMapView *)aMapView layerForAnnotation:(RMAnnotation *)annotation { 

RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"pin-blue.png"]]; 
if ([annotation isKindOfClass:[MyAnnotation class]]) { 
    if ([annotation.annotationType isEqualToString:@"marker"]) { 
     [marker replaceUIImage:[self imageWithImage:[UIImage imageNamed:@"ic_marker.png"] scaledToSize:CGSizeMake(32, 48)]]; 
     [marker setAnchorPoint:CGPointMake(0.5, 1)]; 
     return marker; 
    } else if ([annotation.annotationType isEqualToString:@"path"]) { 
     path.lineWidth = 3; 
     for (int i=0; i<[myCoordinateArray count]; i++) { 
      NSLog(@"my coord count : %d", [myCoordinateArray count]); 
      CLLocationCoordinate2D myLoc = [[myCoordinateArray objectAtIndex:i] coordinate]; 
      if (i>0) { 
       [path addLineToCoordinate:myLoc]; 
      } else { 
       [path moveToCoordinate:myLoc]; 
      } 
     } 
     [path closePath]; 
     return path; 
    } 
} 
return nil; 

}

//

myPin = [[MyAnnotation alloc] init]; 
     [myPin setMapView:mapView]; 

     [myPin setCoordinate:myLatLng]; 
     [myPin setTitle:@"Marker"]; 

     myPin.annotationType = @"marker"; 
     [mapView addAnnotation:myPin]; 
     [mapView setNeedsDisplay]; 

myPath = [[MyAnnotation alloc] init]; 
     [myPath setCoordinate:myLatLng]; 
     myPath.annotationType = @"path"; 
     [mapView addAnnotation:myPath]; 

내가 뭘 잘못 했나요, 아니면 내가 뭔가를 놓친 건가 주석 추가 하시겠습니까? 도와주세요. 미리 감사드립니다.

답변

0

첫 번째로 두 번째 코드 블록에서 setMapView: 또는 setNeedsDisplay을 호출 할 필요가 없습니다.

둘째로, 이것에 대해 어떻게 작동하지 않습니까? 코드가 작동하여지도상의 점과 경로를 모두 보여야하는 것처럼 보입니다.

+0

감사합니다. 이제는 작동하도록 관리 할 수 ​​있습니다. 나는 단지 내가 모르는 뭔가를 놓친다. 어쨌든, 대단히 감사합니다. – majorl3oat

+0

@ majorl3oat 실종 된 내용을 반영하여 질문을 업데이트 해 주실 수 있습니까? 저는 현재 같은 문제에 직면 해 있으며 해결할 수 없습니다! 감사합니다. – Priest

+0

@Priest 정말 유감입니다. 오래 전 이었지만 어떻게 해결했는지 기억이 안납니다. 이제 다른 프로젝트로 옮겼습니다. – majorl3oat