IOS Settings Baidu Map Custom labeling pictures, custom bubbles

Source: Internet
Author: User

#pragma mark-bmkmapviewdelegate

Generate the corresponding view according to Anntation

-(Bmkannotationview *) Mapview: (Bmkmapview *) Mapview viewforannotation: (id <BMKAnnotation>) annotation

{

General annotation

NSString *annotationviewid = @ "Clustermark";

Clusterannotation *cluster = (clusterannotation*) annotation;

Clusterannotationview *annotationview = [[Clusterannotationview alloc] Initwithannotation:annotation reuseIdentifier : Annotationviewid];

Annotationview.size = cluster.size;

Annotationview.canshowcallout = no;//will pop up the black box when you click on the PIN.

annotationview.draggable = no;//prohibit labels from dragging on the map

annotationview.annotation = cluster;

Annotationview.image=[uiimage imagewithdata:[nsdata Datawithcontentsofurl:[nsurl URLWithString: Annotation.subtitle]];

Annotationview.centeroffset=cgpointmake (0,0);

UIView *viewforimage=[[uiview alloc]initwithframe:cgrectmake (0, 0, 110, 110)];

Uiimageview *imageview=[[uiimageview alloc]initwithframe:cgrectmake (0, 0, 110, 110)];

[ImageView setimage:[uiimage imagewithdata:[nsdata Datawithcontentsofurl:[nsurl URLWithString:annotation.subtitle] ]]];

Imageview.layer.maskstobounds=yes;

Imageview.layer.cornerRadius = 10;

[Viewforimage Addsubview:imageview];

Annotationview.image=[self Getimagefromview:viewforimage];

return annotationview;

}


-(UIImage *) Getimagefromview: (UIView *) view{

Uigraphicsbeginimagecontext (view.bounds.size);

[View.layer Renderincontext:uigraphicsgetcurrentcontext ()];

UIImage *image = Uigraphicsgetimagefromcurrentimagecontext ();

Uigraphicsendimagecontext ();

return image;

}


View that appears on the left side of the bubble box and can be customized
Annotationview.leftcalloutaccessoryview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "Icon_ Location.png "];
View customizable on the right side of the bubble box
Annotationview.rightcalloutaccessoryview =selectbutton;
The status of the pop-up bubble box when the callout enters the interface
[Annotationview Setselected:yes Animated:yes];


IOS Settings Baidu Map Custom labeling pictures, custom bubbles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.