百度地图(大头针)

添加大头针

_annotationView= [[BMKAnnotationViewalloc]init];

_annotation= [[BMKPointAnnotationalloc]init];

CLLocationCoordinate2Dcoor;//设置经纬度

coor.latitude= [[_car_infoobjectForKey:@"msg_lat"]doubleValue];//经度  float

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

BMKCoordinateRegionregion;

region.center= coor;把你的经纬度设置为中心点

_annotation.coordinate= coor;

[_mapViewaddAnnotation:_annotation];


//这是一句关键的代码可以让你的地图跟着标注点走

[_mapView setRegion:region animated:YES];

//这句代码是添加标注就显示标准的内容

[_mapView selectAnnotation:_annotationanimated:YES];就是显示你的大头针

自定义大头针

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

if(annotation ==_startPoint) {如果大头针是你想改变那个

初始化并返回一个annotation view

@param annotation关联的annotation对象

@param reuseIdentifier如果要重用view,传入一个字符串,否则设为nil,建议重用view

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

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

annotationView.image= [UIImage imageNamed:@"hha"];设置大头针气泡图片

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

annotationView.draggable=NO;是否可拖拽

returnannotationView;

}

}

待续。。。。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容