码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-07-14 10:02:28      阅读:175      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!