国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

百度地圖自定義大頭針圖片和添加標注

2019-11-07 23:29:47
字體:
來源:轉載
供稿:網友

// 根據anntation生成對應的View

- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation

    NSString * AnnotationViewID = [NSString stringWithFormat:@"renameMark%d",map_i];

    

    newAnnotation = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID];

    // 設置顏色

    ((BMKPinAnnotationView *)newAnnotation).pinColor = BMKPinAnnotationColorPurple;

    // 從天上掉下效果

    ((BMKPinAnnotationView *)newAnnotation).animatesDrop = NO;

    // 設置可拖拽

    ((BMKPinAnnotationView *)newAnnotation).draggable = YES;

    //設置大頭針圖標

    ((BMKPinAnnotationView *)newAnnotation).image = [UIImage imageNamed:@"icon"];

    

    UIView * popView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 53)];

    //設置彈出氣泡圖片

    UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yuanju_gnnr_icon"]];

    image.frame = CGRectMake(0, 0, 100, 60);

    [popView addSubview:image];

    //自定義顯示的內容

    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(10, 7, 100, 11)];

    label.text = @"醫院";

    label.backgroundColor = [UIColor clearColor];

    label.font = [UIFont systemFontOfSize:11];

    label.textColor = [self hexStringToColor:@"#333333"];

    label.textAlignment = NSTextAlignmentLeft;

    [popView addSubview:label];

    

    UILabel * locationLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 25, 100, 18)];

    locationLabel.text = [self.userDefaults objectForKey:@"loc"];

    locationLabel.backgroundColor = [UIColor clearColor];

    locationLabel.font = [UIFont systemFontOfSize:18];

    locationLabel.textColor = [self hexStringToColor:@"#333333"];

    locationLabel.textAlignment = NSTextAlignmentLeft;

    [popView addSubview:locationLabel];

    //根據獲取到的地址來重新設置氣泡的大小

    //地址標簽

    CGRect locationRect = locationLabel.frame;

    locationRect.size.width = [locationLabel sizeThatFits:CGSizeZero].width;

    locationLabel.frame = locationRect;

    //父view寬度

    CGRect poPRect = popView.frame;

    popRect.size.width = [locationLabel sizeThatFits:CGSizeZero].width + 20;

    popView.frame = popRect;

    //設置彈出氣泡圖片

    image.frame = popView.frame;

    

    BMKActionPaopaoView * pView = [[BMKActionPaopaoView alloc]initWithCustomView:popView];

    pView.frame = CGRectMake(0, 0, 100, 60);

    ((BMKPinAnnotationView *)newAnnotation).paopaoView = nil;

    ((BMKPinAnnotationView *)newAnnotation).paopaoView = pView;

    map_i++;

    return newAnnotation;

    

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和龙市| 定州市| 太白县| 贵南县| 乌苏市| 新龙县| 濮阳市| 咸阳市| 米脂县| 五莲县| 吴堡县| 扶沟县| 宁津县| 堆龙德庆县| 鹿邑县| 贵港市| 集贤县| 临邑县| 盈江县| 延庆县| 海南省| 海口市| 康乐县| 孙吴县| 三亚市| 犍为县| 彭泽县| 舒城县| 河西区| 奉化市| 石林| 琼结县| 临高县| 保靖县| 宜阳县| 高淳县| 桓台县| 城市| 金乡县| 淳安县| 梁河县|