首页 > 其他 > 详细

百度地图添加大头针和视图

时间:2015-07-14 10:01:13      阅读:186      评论:0      收藏:0      [点我收藏+]

首先初始化一个要展示的泡泡视图

 
    paopaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 80)];
    paopaoView.layer.cornerRadius = 10;
    paopaoView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    paopaoView.layer.borderWidth = 2;
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 160, 80)];
    label.numberOfLines = 0;
    label.text = @"上地三街36号 吃6块钱的麻辣烫上地三街36号 吃6块钱的麻辣烫上地三街36号 吃6块钱的麻辣烫";
    label.textColor = [UIColor redColor];
    label.font = [UIFont systemFontOfSize:13];
    [paopaoView addSubview:label];

设置坐标点处的annotation

-(void)viewDidAppear:(BOOL)animated{
 
    BMKPointAnnotation *annotation = [[BMKPointAnnotation alloc] init];
    CLLocationCoordinate2D coor;
    coor.latitude = 40.0424920000;
    coor.longitude = 116.3182870000;
    annotation.coordinate = coor;
    [_mapView addAnnotation:annotation];
}

代理方法实现

-(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;
         //大头针图片
        newAnnotationView.image = [UIImage imageNamed:@"1.jpg"];
        newAnnotationView.paopaoView = [[BMKActionPaopaoView alloc]initWithCustomView:paopaoView];
        [newAnnotationView setSelected:YES animated:YES];
        return newAnnotationView;
    }
    return nil;
}

 

百度地图添加大头针和视图

原文:http://www.cnblogs.com/machealking/p/4644599.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!