地圖sdk ios公開課lesson用于在上顯示標記_第1頁
地圖sdk ios公開課lesson用于在上顯示標記_第2頁
地圖sdk ios公開課lesson用于在上顯示標記_第3頁
地圖sdk ios公開課lesson用于在上顯示標記_第4頁
地圖sdk ios公開課lesson用于在上顯示標記_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

iOSSDK了解自定義了解@brief關(guān)聯(lián)的@property(nonatomic,strong)id<MAAnnotation>@brief顯示的@property(nonatomic,strong)UIImage@brief默認情況下,annotationview的中心位于annotation的坐標位置,可以設(shè)置@property(nonatomic)CGPointf 默認情況下, 彈出的氣泡位于正中上方,以設(shè)置改變的偏移使@property(nonatomic)CGPoint@interfaceMAPinAnnotationView:導入標 文-(MAAnnotationView*)mapView:(MAMapView*)mapView{if([annotationisKindOfClass:[MAPointAnnotation{staticNSString*reuseIndetifier=MAAnnotationView*annotationView=(MAAnnotationView*)[mapViewif(annotationView=={annotationView=[[MAAnnotationViewalloc]initWithAnnotation:annotation}annotationView.image=[UIImage//設(shè)置中心點偏移,使得標注底部中間點成為 annotationView.centerOffset=CGPointMake(0,-18);returnannotationView;}return}56@interfaceCustomCalloutView:@property(nonatomic,strong)UIImage*image;@property(nonatomic,copy)NSString*title;@property(nonatomic,copy)NSString*subtitle;

-添加 自定義繼承@interfaceCustomAnnotationView:@property(nonatomic,readonly)CustomCalloutView*calloutView;-(void)setSelected:(BOOL)selected7使用drawRect#pragmamark-draw-{[selfself.layer.shadowOpacity=1.0;self.layer.shadowOffset=CGSizeMake(0.0f,}-{CGContextSetLineWidth(context,CGContextSetFillColorWithColor(context,[UIColorcolorWithRed:0.3green:0.3blue:0.3[selfgetDra }- { CGFloatradius=6.0;midx=CGRectGetMidX(rrect),maxx=CGFloatminy=maxy=CGRectGetMaxY(rrect)-CGContextMoveToPoint(context,midx+kArrorHeight,maxy);CGContextAddLineToPoint(context,midx-kArrorHeight,CGContextAddArcToPoint(context,minx,maxy,minx,miny,radius);CGContextAddArcToPoint(context,minx,minx,maxx,miny,radius);CGContextAddArcToPoint(context,maxx,miny,maxx,maxx,radius);CGContextAddArcToPoint(context,maxx,maxy,midx,maxy,radius); 自定義修改calloutView@synthesizecalloutView={

修改calloutViewif(self.selected=={}if{

新建并添加if(self.calloutView=={self.calloutView.center=CGPointMake(CGRectGetWidth(self.bounds)/2.f+self.calloutOffset.x,}}

[self}{}

修改MAMapView的回調(diào)方法中的annotationView-(MAAnnotationView*)mapView:(MAMapView*)mapView{…CustomAnnotationView*annotationView=(CustomAnnotationView*)[mapViewdequeueReusableAnnotationViewWithIdentifier:reuseIndetifier];if(annotationView==nil){annotationView=[[CustomAnnotationViewalloc]initWithAnnotation:annotation}…}9自定義彈出氣泡添加@interfaceCustomCalloutView@property(nonatomic,strong)UIImageView*portraitView;@property(nonatomic,strong)UILabel*subtitleLabel;@property(nonatomic,strong)UILabel*titleLabel;@implementation-{self=[superinitWithFrame:frame];if(self){self.backgroundColor=[UIColorclearColor];[selfinitSubViews];}return}-{#define #define #define #define #define //self.portraitView=[[UIImageViewalloc]initWithFrame:CGRectMake(kPortraitMargin,kPortraitMargin,kPortraitWidth,self.portraitView.backgroundColor=[UIColorblackColor];[selfaddSubview:self.portraitView];self.titleLabel=[[UILabelalloc]initWithFrame:CGRectMake(kPortraitMargin*2+kPortraitWidth,kPortraitMargin,kTitleWidth,kTitleHeight)];self.titleLabel.font=[UIFontboldSystemFontOfSize:14];self.titleLabel.textColor=[UIColorwhiteColor];self.titleLabel.text=@"titletitletitletitle";[selfaddSubview:self.titleLabel];self.subtitleLabel=[[UILabelalloc]initWithFrame:CGRectMake(kPortraitMargin*2+kPortraitWidth,kPortraitMargin*2+kTitleHeight,kTitleWidth,kTitleHeight)];self.subtitleLabel.font=[UIFontsystemFontOfSize:12];self.subtitleLabel.textColor=[UIColorlightGrayColor];[selfaddSubview:self.subtitleLabel];} 綁定數(shù)據(jù)和#pragmamark--(void)setTitle:(NSString{self.titleLabel.text=}-(void)setSubtitle:(NSString{self.subtitleLabel.text=}-(void)setImage:(UIImage{self.portraitView.image=}自定義選中時將數(shù)據(jù)傳給@implementationCustomAnnotationView@synthesizecalloutView=_calloutView;-(void)setSelected:(BOOL)selected{…if{if(self.calloutView=={self.calloutView=[[CustomCalloutViewalloc]initWithFrame:CGRectMake(0,0,kCalloutWidth,kCalloutHeight)];self.calloutView.center=CGPointMake(CGRectGetWidth(self.bounds)/+-CGRectGetHeight(self.calloutView.bounds)/2.f+}self.calloutView.image=[UIImageimageNamed:@"building"];self.calloutViewself.calloutView.image=[UIImageimageNamed:@"building"];self.calloutView.title=self.annotation.title;self.calloutView.subtitle=self.annotation.subtitle;}…}自定義彈出氣泡修復:選中氣泡時認為選中點擊氣泡時,認為是選中annotation@implementationCustomAnnotationView@synthesizecalloutView=_calloutView;#pragmamark-…//重寫此函數(shù),用以實現(xiàn)點擊calloutView判斷為點擊該

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論