IOS 바 이 두 맵 사용자 정의 큰 바늘 과 기포 스타일 구현

1.사용자 정의 큰 바늘 과 기포

//   anntation     View 
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation 
{ 
 NSString *AnnotationViewID = [NSString stringWithFormat:@"renameMark%d",i]; 
 newAnnotation = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID]; 
 //      
 ((BMKPinAnnotationView*)newAnnotation).pinColor = BMKPinAnnotationColorPurple; 
 //         
 ((BMKPinAnnotationView*)newAnnotation).animatesDrop = YES; 
 //       
 ((BMKPinAnnotationView*)newAnnotation).draggable = YES; 
 //        
 ((BMKPinAnnotationView*)newAnnotation).image = [UIImage imageNamed:@"zhaohuoche"]; 
 UIView *popView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 60)]; 
 //         
 UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"wenzi"]]; 
 image.frame = CGRectMake(0, 0, 100, 60); 
 [popView addSubview:image]; 
 //         
 UILabel *driverName = [[UILabel alloc]initWithFrame:CGRectMake(0, 3, 100, 20)]; 
 driverName.text = @" XX  "; 
 driverName.backgroundColor = [UIColor clearColor]; 
 driverName.font = [UIFont systemFontOfSize:14]; 
 driverName.textColor = [UIColor whiteColor]; 
 driverName.textAlignment = NSTextAlignmentCenter; 
 [popView addSubview:driverName]; 
 UILabel *carName = [[UILabel alloc]initWithFrame:CGRectMake(0, 25, 100, 20)]; 
 carName.text = @" A123456"; 
 carName.backgroundColor = [UIColor clearColor]; 
 carName.font = [UIFont systemFontOfSize:14]; 
 carName.textColor = [UIColor whiteColor]; 
 carName.textAlignment = NSTextAlignmentCenter; 
 [popView addSubview:carName]; 
 BMKActionPaopaoView *pView = [[BMKActionPaopaoView alloc]initWithCustomView:popView]; 
 pView.frame = CGRectMake(0, 0, 100, 60); 
 ((BMKPinAnnotationView*)newAnnotation).paopaoView = nil; 
 ((BMKPinAnnotationView*)newAnnotation).paopaoView = pView; 
 i++; 
 return newAnnotation; 
} 
2.기포 사용자 정의 내용
 
 가장 간단 하고 직접적인 방법...
UIView 사용자 정의
핵심 코드 는 다음 과 같 습 니 다.

//            
-(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
{
 BMKAnnotationView *annotationView=[[BMKAnnotationViewalloc]initWithAnnotation:annotationreuseIdentifier:@"myAnnotation"];
 annotationView.image =[UIImageimageNamed:@"bike.gif"];
 //       
 UIView *areaPaoView=[[UIViewalloc]initWithFrame:CGRectMake(0, 0, 200, 100)];
 areaPaoView.layer.cornerRadius=8;
 areaPaoView.layer.masksToBounds=YES;
 areaPaoView.layer.contents =(id)[UIImageimageNamed:@"pao.png"].CGImage;//          
 //areaPaoView.backgroundColor=[UIColor whiteColor];
  if ([annotation.titleisEqualToString:@"1"]) { //  title    1,                
      UILabel * labelNo = [[UILabelalloc]initWithFrame:CGRectMake(10, 0, 200, 30)];
   labelNo.text =[NSStringstringWithFormat:@"    :%@"];
   labelNo.textColor = [UIColorblackColor];
   labelNo.backgroundColor = [UIColorclearColor];
   [areaPaoViewaddSubview:labelNo];
   UILabel * labelStationName = [[UILabelalloc]initWithFrame:CGRectMake(10, 20, 200, 30)];
   labelStationName.text = [NSStringstringWithFormat:@"    :    "];
   labelStationName.textColor = [UIColorblackColor];
   labelStationName.backgroundColor = [UIColorclearColor];
   [areaPaoViewaddSubview:labelStationName];
   UILabel * labelSumNum = [[UILabelalloc]initWithFrame:CGRectMake(10, 40, 200, 30)];
   labelSumNum.text = [NSStringstringWithFormat:@"   :30"];
   labelSumNum.textColor = [UIColorblackColor];
   labelSumNum.backgroundColor = [UIColorclearColor];
   [areaPaoViewaddSubview:labelSumNum];
   UILabel * labelBicycleNum = [[UILabelalloc]initWithFrame:CGRectMake(10, 60, 200, 30)];
   labelBicycleNum.text = [NSStringstringWithFormat:@"   :20"];
   labelBicycleNum.textColor = [UIColorblackColor];
   labelBicycleNum.backgroundColor = [UIColorclearColor];
   [areaPaoViewaddSubview:labelBicycleNum];
 } 
 BMKActionPaopaoView *paopao=[[BMKActionPaopaoViewalloc]initWithCustomView:areaPaoView];
 annotationView.paopaoView=paopao;
 return annotationView;
}
3.사용자 정의 기포 추가
1.우선 여러 개의 레이 블 과 사용자 정의 기포 추가
사용자 정의 레이 블 추가

[_mapView addAnnotations:array];
arry 에 레이 블(BMKPointAnnotation)을 표시 하 는 배열 을 넣 습 니 다.이 방법 은 여러 개의 레이 블 을 추가 합 니 다.
여러 개의 레이 블 을 추가 할 때 다음 프 록 시 방법 을 실행 합 니 다.

#pragma mark -- BMKMapdelegate
/**
 *  anntation     View
 *@param mapView   View
 *@param annotation      
 *@return      View
 */
-(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation
{
 if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
  BMKPinAnnotationView *newAnnotationView = [[BMKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"];
  newAnnotationView.animatesDrop = YES;
  newAnnotationView.annotation = annotation;
  //         ,   BMKPointAnnotation,              
  MyBMKPointAnnotation *tt = (MyBMKPointAnnotation *)annotation;
  //    ,        ,          
  if (tt.profNumber == 100000) {
   newAnnotationView.image = [UIImage imageNamed:@"ic_map_mode_category_merchants_normal.png"];
  }else if (tt.profNumber == 100001){
  }
  //  popView   ,         
  double popViewH = 60;
  if (annotation.subtitle == nil) {
   popViewH = 38;
  }
  UIView *popView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth-100, popViewH)];
  popView.backgroundColor = [UIColor whiteColor];
  [popView.layer setMasksToBounds:YES];
  [popView.layer setCornerRadius:3.0];
  popView.alpha = 0.9;
//  //        
//  UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:tt.imgPath]];
//  image.frame = CGRectMake(0, 160, 50, 60);
//  [popView addSubview:image];
  //        ,      popView 
  UILabel *driverName = [[UILabel alloc]initWithFrame:CGRectMake(8, 4, 160, 30)];
  driverName.text = annotation.title;
  driverName.numberOfLines = 0;
  driverName.backgroundColor = [UIColor clearColor];
  driverName.font = [UIFont systemFontOfSize:15];
  driverName.textColor = [UIColor blackColor];
  driverName.textAlignment = NSTextAlignmentLeft;
  [popView addSubview:driverName];
  UILabel *carName = [[UILabel alloc]initWithFrame:CGRectMake(8, 30, 180, 30)];
  carName.text = annotation.subtitle;
  carName.backgroundColor = [UIColor clearColor];
  carName.font = [UIFont systemFontOfSize:11];
  carName.textColor = [UIColor lightGrayColor];
  carName.textAlignment = NSTextAlignmentLeft;
  [popView addSubview:carName];
  if (annotation.subtitle != nil) {
  UIButton *searchBn = [[UIButton alloc]initWithFrame:CGRectMake(170, 0, 50, 60)];
  [searchBn setTitle:@"    " forState:UIControlStateNormal];
  searchBn.backgroundColor = mainColor;
   searchBn.titleLabel.numberOfLines = 0;
  [searchBn addTarget:self action:@selector(searchLine)];
  [popView addSubview:searchBn];
  }
  BMKActionPaopaoView *pView = [[BMKActionPaopaoView alloc]initWithCustomView:popView];
  pView.frame = CGRectMake(0, 0, ScreenWidth-100, popViewH);
  ((BMKPinAnnotationView*)newAnnotationView).paopaoView = nil;
  ((BMKPinAnnotationView*)newAnnotationView).paopaoView = pView;
  return newAnnotationView;
 }
 return nil;
}
표시 와 기포 응답 방법 을 클릭 하 십시오.

/**
 *      annotation views ,     
 * @param mapView   View
 * @param views    annotation views
 */
- (void)mapView:(BMKMapView *)mapView didSelectAnnotationView:(BMKAnnotationView *)view
{
 _shopCoor = view.annotation.coordinate;
}
/**
 *         
 * @param mapView   
 * @param view annotation
 */
- (void)mapView:(BMKMapView *)mapView annotationViewForBubble:(BMKAnnotationView *)view
{
 MyBMKPointAnnotation *tt = (MyBMKPointAnnotation *)view.annotation;
 if (tt.shopID) {
  BusinessIfonUVC *BusinessIfonVC = [[BusinessIfonUVC alloc]init];
  BusinessIfonVC.shopId = tt.shopID;
  [self.navigationController pushViewController:BusinessIfonVC animated:YES];
 }
}
2.노선 검색,경로 계획,거리 이름 획득 등 기능 실현
경위도 로 주소,역 지리 인 코딩 가 져 오기

-(void)getStartAddress
{
 //    
 CLGeocoder *Geocoder = [[CLGeocoder alloc]init];
 CLGeocodeCompletionHandler handler = ^(NSArray *place,NSError *error){
  for(CLPlacemark *placemark in place){
   NSString *tmp = [[NSString alloc]init];
   tmp = placemark.subThoroughfare;
   if (tmp == nil) {
    tmp = @"";
   }
   NSString *startAdr = [[NSString alloc]initWithFormat:@"%@%@",placemark.thoroughfare,tmp];
   _startCityText.text = placemark.locality;
   if ([startAdr isEqualToString:@"(null)"]) {
    _startAddrText.text = @"      ";
   }else{
   _startAddrText.text = startAdr;
   }
 }
 };
 CLLocation *loc = [[CLLocation alloc]initWithLatitude:self.startCoor.latitude longitude:self.startCoor.longitude];
 [Geocoder reverseGeocodeLocation:loc completionHandler:handler];
}
경로 검색 은 이 부분 이 정리 되 지 않 아 승차 와 환 승 정 보 를 라인 인 포,steps 등 모델 에 넣 었 다.

- (void)onGetTransitRouteResult:(BMKRouteSearch*)searcher result:(BMKTransitRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
 NSMutableArray *lineArr = [[NSMutableArray alloc]init];
 NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
 [_mapView removeAnnotations:array];
 array = [NSArray arrayWithArray:_mapView.overlays];
 [_mapView removeOverlays:array];
 if (error == BMK_SEARCH_NO_ERROR) {
  for(int j = 0; j < [result.routes count];j++)
  {
  NSMutableArray *busTitleArr = [[NSMutableArray alloc]init];
  NSMutableArray *lineStepsArr = [[NSMutableArray alloc]init];
  NSMutableArray *stepsArr = [[NSMutableArray alloc]init];
 //      
  LineInfoModel *lineInfo = [[LineInfoModel alloc]init];
  BMKTransitRouteLine* plan = (BMKTransitRouteLine*)[result.routes objectAtIndex:j];
 //    :      
  lineInfo.distance = plan.distance;
 //    :        
  lineInfo.dates = plan.duration.dates;
  lineInfo.hours = plan.duration.hours;
  lineInfo.minutes = plan.duration.minutes;
  lineInfo.seconds = plan.duration.seconds;
 //      
  lineInfo.planStepsArr = plan.steps;
  //             
  int size = [plan.steps count];
  int planPointCounts = 0;
  for (int i = 0; i < size; i++) {
   BMKTransitStep* transitStep = [plan.steps objectAtIndex:i];
 //    :        
   DLog(@"%@",transitStep.vehicleInfo.title);
   if (transitStep.vehicleInfo.title) {
    [busTitleArr addObject:transitStep.vehicleInfo.title];
   }
 //    :      
   if (transitStep.instruction) {
    transitStep.instruction = [transitStep.instruction stringByReplacingOccurrencesOfString:@"<font color=\"#313233\">" withString:@""];
    [lineStepsArr addObject:transitStep.instruction];
   }
   DLog(@"%@ %@",transitStep.vehicleInfo.title,transitStep.instruction);
   if(i==0){
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item.coordinate = plan.starting.location;
    item.title = @"  ";
    item.type = 0;
//    [_mapView addAnnotation:item]; //       
//  
//
    [stepsArr addObject:item];
   }else if(i==size-1){
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item.coordinate = plan.terminal.location;
    item.title = @"  ";
    item.type = 1;
    [stepsArr addObject:item];
//    [_mapView addAnnotation:item]; //       
//   
   }
   RouteAnnotation* item = [[RouteAnnotation alloc]init];
   item.coordinate = transitStep.entrace.location;
   item.title = transitStep.instruction;
   transitStep.instruction = [transitStep.instruction stringByReplacingOccurrencesOfString:@"<font color=\"#313233\">" withString:@""];
   item.type = 3;
   [stepsArr addObject:item];
//   [_mapView addAnnotation:item];
// 
//   
//   //       
   planPointCounts += transitStep.pointsCount;
  }
  lineInfo.vehicleInfoArr = busTitleArr;
  lineInfo.lineStepsArr = lineStepsArr;
  lineInfo.stepsArr = stepsArr;
  lineInfo.planPointCounts = planPointCounts;
  [lineArr addObject:lineInfo];
//  //   
//  BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
//  int i = 0;
//  for (int j = 0; j < size; j++) {
//   BMKTransitStep* transitStep = [plan.steps objectAtIndex:j];
//   int k=0;
//   for(k=0;k<transitStep.pointsCount;k++) {
//    temppoints[i].x = transitStep.points[k].x;
//    temppoints[i].y = transitStep.points[k].y;
//    i++;
//   }
  }
  self.lineStatusArr = lineArr;
  //   points  BMKPolyline
//  BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
//  [_mapView addOverlay:polyLine]; //     overlay
//  delete []temppoints;
//  }
  [_tableView reloadData];
 }
}
- (void)onGetDrivingRouteResult:(BMKRouteSearch*)searcher result:(BMKDrivingRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
 NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
 [_mapView removeAnnotations:array];
 array = [NSArray arrayWithArray:_mapView.overlays];
 [_mapView removeOverlays:array];
 if (error == BMK_SEARCH_NO_ERROR) {
  BMKDrivingRouteLine* plan = (BMKDrivingRouteLine*)[result.routes objectAtIndex:0];
  //             
  int size = [plan.steps count];
  int planPointCounts = 0;
  for (int i = 0; i < size; i++) {
   BMKDrivingStep* transitStep = [plan.steps objectAtIndex:i];
   if(i==0){
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item.coordinate = plan.starting.location;
    item.title = @"  ";
    item.type = 0;
    [_mapView addAnnotation:item]; //       
   }else if(i==size-1){
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item.coordinate = plan.terminal.location;
    item.title = @"  ";
    item.type = 1;
    [_mapView addAnnotation:item]; //       
   }
   //  annotation  
   RouteAnnotation* item = [[RouteAnnotation alloc]init];
   item.coordinate = transitStep.entrace.location;
   item.title = transitStep.entraceInstruction;
   item.degree = transitStep.direction * 30;
   item.type = 4;
   [_mapView addAnnotation:item];
   //       
   planPointCounts += transitStep.pointsCount;
  }
  //      
  if (plan.wayPoints) {
   for (BMKPlanNode* tempNode in plan.wayPoints) {
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item = [[RouteAnnotation alloc]init];
    item.coordinate = tempNode.pt;
    item.type = 5;
    item.title = tempNode.name;
    [_mapView addAnnotation:item];
   }
  }
  //   
  BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
  int i = 0;
  for (int j = 0; j < size; j++) {
   BMKDrivingStep* transitStep = [plan.steps objectAtIndex:j];
   int k=0;
   for(k=0;k<transitStep.pointsCount;k++) {
    temppoints[i].x = transitStep.points[k].x;
    temppoints[i].y = transitStep.points[k].y;
    i++;
   }
  }
  //   points  BMKPolyline
  BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
  [_mapView addOverlay:polyLine]; //     overlay
  delete []temppoints;
 }
}
- (void)onGetWalkingRouteResult:(BMKRouteSearch*)searcher result:(BMKWalkingRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
 NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
 [_mapView removeAnnotations:array];
 array = [NSArray arrayWithArray:_mapView.overlays];
 [_mapView removeOverlays:array];
 if (error == BMK_SEARCH_NO_ERROR) {
  BMKWalkingRouteLine* plan = (BMKWalkingRouteLine*)[result.routes objectAtIndex:0];
  int size = [plan.steps count];
  int planPointCounts = 0;
  for (int i = 0; i < size; i++) {
   BMKWalkingStep* transitStep = [plan.steps objectAtIndex:i];
   if(i==0){
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item.coordinate = plan.starting.location;
    item.title = @"  ";
    item.type = 0;
    [_mapView addAnnotation:item]; //       
   }else if(i==size-1){
    RouteAnnotation* item = [[RouteAnnotation alloc]init];
    item.coordinate = plan.terminal.location;
    item.title = @"  ";
    item.type = 1;
    [_mapView addAnnotation:item]; //       
   }
   //  annotation  
   RouteAnnotation* item = [[RouteAnnotation alloc]init];
   item.coordinate = transitStep.entrace.location;
   item.title = transitStep.entraceInstruction;
   item.degree = transitStep.direction * 30;
   item.type = 4;
   [_mapView addAnnotation:item];
   //       
   planPointCounts += transitStep.pointsCount;
  }
  //   
  BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
  int i = 0;
  for (int j = 0; j < size; j++) {
   BMKWalkingStep* transitStep = [plan.steps objectAtIndex:j];
   int k=0;
   for(k=0;k<transitStep.pointsCount;k++) {
    temppoints[i].x = transitStep.points[k].x;
    temppoints[i].y = transitStep.points[k].y;
    i++;
   }
  }
  //   points  BMKPolyline
  BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
  [_mapView addOverlay:polyLine]; //     overlay
  delete []temppoints;
 }
}
3.경로 그리 기
내 가 여기 서 실현 한 것 은 다른 컨트롤 러 로 넘 어 가 는 것 이다.다음은 그 가 필요 로 하 는 데이터 이다.

//    
@property (nonatomic,assign) int distance;
//      
@property (nonatomic,assign) int dates;
@property (nonatomic,assign) int hours;
@property (nonatomic,assign) int minutes;
@property (nonatomic,assign) int seconds;
//      
@property (nonatomic,strong) NSArray *vehicleInfoArr;
//    
@property (nonatomic,strong) NSArray *lineStepsArr;
//  
@property (nonatomic,strong) NSArray *stepsArr;
//     
@property (nonatomic,assign) int planPointCounts;
//   
@property (nonatomic,strong) NSArray *planStepsArr;
다음은 경 로 를 그 리 는 것 이다.승차 데이터 에 대한 전 시 는 바로 tableview 에 제스처 를 추가 하고 설명 하지 않 는 것 이다.

-(void)drawMap
{
 BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init];
 item = [_lineInfo.stepsArr firstObject];
 [_mapView setCenterCoordinate:item.coordinate];
 [_mapView addAnnotations:_lineInfo.stepsArr];
 BMKMapPoint* temppoints = (BMKMapPoint *)malloc(sizeof(CLLocationCoordinate2D) * _lineInfo.planPointCounts);
 int i = 0;
 for (int j = 0; j < [_lineInfo.planStepsArr count]; j++) {
   BMKTransitStep* transitStep = [_lineInfo.planStepsArr objectAtIndex:j];
   int k=0;
   for(k=0;k<transitStep.pointsCount;k++) {
    temppoints[i].x = transitStep.points[k].x;
    temppoints[i].y = transitStep.points[k].y;
    i++;
  }
 }
 BMKPolyline* polyLine =[BMKPolyline polylineWithPoints:temppoints count:_lineInfo.planPointCounts];
 if (nil != polyLine) {
   [_mapView addOverlay:polyLine]; //     overlay
 }
 free(temppoints);
}
- (BMKOverlayView*)mapView:(BMKMapView *)map viewForOverlay:(id<BMKOverlay>)overlay
{
 if ([overlay isKindOfClass:[BMKPolyline class]]) {
  BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay];
  polylineView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:1];
  polylineView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];
  polylineView.lineWidth = 3.0;
  return polylineView;
 }
 return nil;
}
//       ,   
- (BMKAnnotationView*)getRouteAnnotationView:(BMKMapView *)mapview viewForAnnotation:(MyBMKPointAnnotation*)routeAnnotation
{
 BMKAnnotationView* view = nil;
 switch (routeAnnotation.type) {
  case 0:
  {
   view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"start_node"];
   if (view == nil) {
    view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"start_node"];
    view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_start.png"]];
    view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));
    view.canShowCallout = TRUE;
   }
   view.annotation = routeAnnotation;
  }
   break;
  case 1:
  {
   view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"end_node"];
   if (view == nil) {
    view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"end_node"];
    view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_end.png"]];
    view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));
    view.canShowCallout = TRUE;
   }
   view.annotation = routeAnnotation;
  }
   break;
  case 2:
  {
   view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"bus_node"];
   if (view == nil) {
    view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"bus_node"];
    view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_bus.png"]];
    view.canShowCallout = TRUE;
   }
   view.annotation = routeAnnotation;
  }
   break;
  case 3:
  {
   view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"rail_node"];
   if (view == nil) {
    view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"rail_node"];
    view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_rail.png"]];
    view.canShowCallout = TRUE;
   }
   view.annotation = routeAnnotation;
  }
   break;
  case 4:
  {
   view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"route_node"];
   if (view == nil) {
    view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"route_node"];
    view.canShowCallout = TRUE;
   } else {
    [view setNeedsDisplay];
   }
   UIImage* image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_direction.png"]];
   view.image = [image imageRotatedByDegrees:routeAnnotation.degree];
   view.annotation = routeAnnotation;
  }
   break;
  case 5:
  {
   view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"waypoint_node"];
   if (view == nil) {
    view = [[BMKAnnotationView alloc]initWithAnnotation:routeAnnotation reuseIdentifier:@"waypoint_node"];
    view.canShowCallout = TRUE;
   } else {
    [view setNeedsDisplay];
   }
   UIImage* image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_waypoint.png"]];
   view.image = [image imageRotatedByDegrees:routeAnnotation.degree];
   view.annotation = routeAnnotation;
  }
   break;
  default:
   break;
 }
 return view;
}
- (BMKAnnotationView *)mapView:(BMKMapView *)view viewForAnnotation:(id <BMKAnnotation>)annotation
{
 if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
  return [self getRouteAnnotationView:view viewForAnnotation:(MyBMKPointAnnotation *)annotation];
 }
 return nil;
}
- (UIImage*)imageRotatedByDegrees:(CGFloat)degrees
{
 CGFloat width = CGImageGetWidth(self.CGImage);
 CGFloat height = CGImageGetHeight(self.CGImage);
 CGSize rotatedSize;
 rotatedSize.width = width;
 rotatedSize.height = height;
 UIGraphicsBeginImageContext(rotatedSize);
 CGContextRef bitmap = UIGraphicsGetCurrentContext();
 CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2);
 CGContextRotateCTM(bitmap, degrees * M_PI / 180);
 CGContextRotateCTM(bitmap, M_PI);
 CGContextScaleCTM(bitmap, -1.0, 1.0);
 CGContextDrawImage(bitmap, CGRectMake(-rotatedSize.width/2, -rotatedSize.height/2, rotatedSize.width, rotatedSize.height), self.CGImage);
 UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 return newImage;
}
다른 방법

/////////////////////////////// 
if ([annotation isKindOfClass:[SiteAnnotation class]]) { 
   static NSString *identifier = @"MKAnnotationView"; 
   BMKAnnotationView *pin = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 
   if (pin == nil) { 
    pin = [[BMKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
    //              ,                     
    pin.image = [UIImage imageNamed:@"default_marker.png"]; 
   } 
   pin.annotation = annotation; 
   pin.paopaoView = [[BMKActionPaopaoView alloc]initWithCustomView:[[UIView alloc] init]]; 
   return pin; 
  } 
위 와 같이 소 편 이 소개 한 IOS 는 바 이 두 맵 의 사용자 정의 큰 바늘 과 기포 스타일 을 실현 하여 여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.소 편 은 바로 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!

좋은 웹페이지 즐겨찾기