http://potter528.bj.bdysite.com
1.首先根據(jù)百度開發(fā)者文檔將環(huán)境和各種系統(tǒng)FrameWork導(dǎo)入
先創(chuàng)建一個(gè)mapview(BMKMapView)
然后在viewController中的viewDidAppear方法中添加Annotation
如果想改變大頭針的顏色和形狀,可以實(shí)現(xiàn)其代理方法
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation
{
if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
BMKPinAnnotationView *newAnnotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"];
newAnnotationView.pinColor = BMKPinAnnotationColorPurple;
newAnnotationView.animatesDrop = YES;// 設(shè)置該標(biāo)注點(diǎn)動(dòng)畫顯示
return newAnnotationView;
}
return nil;
}
從現(xiàn)在開始就一步一步就你做
1.實(shí)現(xiàn)mapview有幾種方式
1.1第一種:IBOutlet BMKMapView *mapView;(與storyboard中相應(yīng)的view進(jìn)行關(guān)聯(lián))
1.2第二種:設(shè)置成屬性,并在viewDidLoad中初始化
1.3第三種:設(shè)置成成員變量的方式,同上
2.在ViewController中重寫viewDidAppear方法
BMKPointAnnotation *point1 = [[BMKPointAnnotation alloc]init];
point1.coordinate = CLLocationCoordinate2DMake(39, 116);
point1.title = @"北京";
[mapView addAnnotation:point1];
2.1其代理方法一同寫上即可.