//根据anntation生成对应的View
- (BMKAnnotationView*)mapView:(BMKMapView*)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
{
NSString* AnnotationViewID = [NSStringstringWithFormat:@"renameMark%d",map_i];
newAnnotation= [[BMKPinAnnotationViewalloc]initWithAnnotation:annotationreuseIdentifier:AnnotationViewID];
//设置颜色
((BMKPinAnnotationView*)newAnnotation).pinColor=BMKPinAnnotationColorPurple;
//从天上掉下效果
((BMKPinAnnotationView*)newAnnotation).animatesDrop=NO;
//设置可拖拽
((BMKPinAnnotationView*)newAnnotation).draggable=YES;
//设置大头针图标
((BMKPinAnnotationView*)newAnnotation).image= [UIImageimageNamed:@"icon"];
UIView* popView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,100,53)];
//设置弹出气泡图片
UIImageView*image = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"yuanju_gnnr_icon"]];
image.frame=CGRectMake(0,0,100,60);
[popViewaddSubview:image];
//自定义显示的内容
UILabel* label = [[UILabelalloc]initWithFrame:CGRectMake(10,7,100,11)];
label.text=@"医院";
label.backgroundColor= [UIColorclearColor];
label.font= [UIFontsystemFontOfSize:11];
label.textColor= [selfhexStringToColor:@"#333333"];
label.textAlignment=NSTextAlignmentLeft;
[popViewaddSubview:label];
UILabel* locationLabel = [[UILabelalloc]initWithFrame:CGRectMake(10,25,100,18)];
locationLabel.text= [self.userDefaultsobjectForKey:@"loc"];
locationLabel.backgroundColor= [UIColorclearColor];
locationLabel.font= [UIFontsystemFontOfSize:18];
locationLabel.textColor= [selfhexStringToColor:@"#333333"];
locationLabel.textAlignment=NSTextAlignmentLeft;
[popViewaddSubview:locationLabel];
//根据获取到的地址来重新设置气泡的大小
//地址标签
CGRectlocationRect = locationLabel.frame;
locationRect.size.width= [locationLabelsizeThatFits:CGSizeZero].width;
locationLabel.frame= locationRect;
//父view宽度
CGRectpopRect = popView.frame;
popRect.size.width= [locationLabelsizeThatFits:CGSizeZero].width+20;
popView.frame= popRect;
//设置弹出气泡图片
image.frame= popView.frame;
BMKActionPaopaoView* pView = [[BMKActionPaopaoViewalloc]initWithCustomView:popView];
pView.frame=CGRectMake(0,0,100,60);
((BMKPinAnnotationView*)newAnnotation).paopaoView=nil;
((BMKPinAnnotationView*)newAnnotation).paopaoView= pView;
map_i++;
returnnewAnnotation;
}