zoukankan      html  css  js  c++  java
  • 百度地图添加大头针和视图

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

     
        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;
    }
  • 相关阅读:
    SQL基础篇——如何搭建一个数据库
    SQL基础篇---基本概念解析
    联合体与结构体的区别
    结构体和它在链表中的使用
    火线零线地线
    第十二章 泛型
    Winform 控件使用集锦
    全局钩子和局部钩子
    第八章 方法
    第七章 常量和字段
  • 原文地址:https://www.cnblogs.com/machealking/p/4644599.html
Copyright © 2011-2022 走看看