百度地圖(大頭針)

添加大頭針

_annotationView= [[BMKAnnotationViewalloc]init];

_annotation= [[BMKPointAnnotationalloc]init];

CLLocationCoordinate2Dcoor;//設(shè)置經(jīng)緯度

coor.latitude= [[_car_infoobjectForKey:@"msg_lat"]doubleValue];//經(jīng)度 ?float

coor.longitude= [[_car_infoobjectForKey:@"msg_lon"]doubleValue];//緯度

BMKCoordinateRegionregion;

region.center= coor;把你的經(jīng)緯度設(shè)置為中心點(diǎn)

_annotation.coordinate= coor;

[_mapViewaddAnnotation:_annotation];


//這是一句關(guān)鍵的代碼可以讓你的地圖跟著標(biāo)注點(diǎn)走

[_mapView setRegion:region animated:YES];

//這句代碼是添加標(biāo)注就顯示標(biāo)準(zhǔn)的內(nèi)容

[_mapView selectAnnotation:_annotationanimated:YES];就是顯示你的大頭針

自定義大頭針

- (BMKAnnotationView*)mapView:(BMKMapView*)mapView viewForAnnotation:(id)annotation{\

if(annotation ==_startPoint) {如果大頭針是你想改變那個(gè)

初始化并返回一個(gè)annotation view

@param annotation關(guān)聯(lián)的annotation對(duì)象

@param reuseIdentifier如果要重用view,傳入一個(gè)字符串,否則設(shè)為nil,建議重用view

@return初始化成功則返回annotation view,否則返回nil

BMKPinAnnotationView *annotationView = [[BMKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"];

annotationView.image= [UIImage imageNamed:@"hha"];設(shè)置大頭針氣泡圖片

從天上掉下效果annotationView.animatesDrop = YES;

annotationView.draggable=NO;是否可拖拽

returnannotationView;

}

}

待續(xù)。。。。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容