百度地图自定义大头针图片和添加标注
来源:互联网 发布:云之家软件 编辑:程序博客网 时间:2024/05/16 12:05
// 根据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;
}
- 百度地图自定义大头针图片和添加标注
- 百度地图添加多个大头针自定义图片
- 百度地图大头针图片的自定义
- 自定义:地图标注(大头针)
- 百度地图自定义大头针
- 百度地图自定义弹出气泡和大头针
- IOS百度地图自定义大头针和气泡
- IOS百度地图自定义大头针和气泡
- iOS-百度地图添加标注自定义气泡
- 百度地图上自定义添加一个标注
- iOS 百度地图自定义大头针。
- iOS 百度地图_自定义Annotation大头针_修改大头针图片
- iOS 百度地图_自定义Annotation大头针_修改大头针图片
- 百度地图使用(二)自定义大头针和弹出气泡
- 百度地图使用-自定义大头针和弹出气泡
- 百度地图使用(二)自定义大头针和弹出气泡
- iOS百度地图自定义大头针和气泡内的内容
- iOS中设置百度地图自定义标注图片,自定义泡泡
- 【Oracle学习】之 表空间
- javaWEB总结(24):相对路径和绝对路径
- React之组件
- CentOS安装monitorix
- 限制不能打开同名程序
- 百度地图自定义大头针图片和添加标注
- Spring MVC 自定义Validator
- Vue2.0简易案例
- react知识点
- 蓝桥杯进制转换JAVA
- Cocoapods详解之---进阶篇2
- 基于CMake的JNI开发探索
- 在AE中通过指定中心点和半径画圆
- Vue笔记二:进阶[译]用Webpack构建Vue