iOS如何在百度地图添加多个标注
- (void) viewDidAppear:(BOOL)animated {
for (int i = 0; i < 3; i++) {
BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
CLLocationCoordinate2D coor;
coor.latitude = 39.915 + i*10;
coor.longitude = 116.404 + i*10;
annotation.coordinate = coor;
annotation.title = @"这里是北京";
[_mapView addAnnotation:annotation];
}
}
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation{
if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
BMKPinAnnotationView *newAnnotationView = (BMKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationView"];
newAnnotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"AnnotationView"];
newAnnotationView.pinColor = BMKPinAnnotationColorPurple;
newAnnotationView.animatesDrop = YES;// 设置该标注点动画显示
return newAnnotationView;
}
return nil;
}
上面的代码只显示一个标注,如果是调用系统MapKit的库就是显示多个标注,不知道百度地图是如何显示多个标注的。
袏掱D自甴
10 years, 9 months ago