- (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view {
NSLog(@"选中了标注%f, %f",view.annotation.coordinate.latitude, view.annotation.coordinate.longitude);
WeakSelf;
UIAlertController *alerController = [UIAlertController alertControllerWithTitle:@"导航" message:@"选择导航方式" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"百度地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
// [view setSelected:NO animated:YES]; //有BUG
// view.selected = NO; //有BUG
// 取消选中正确方式
StrongSelf;
for (id <MAAnnotation>annotation in strongSelf.mapView.annotations) {
[strongSelf.mapView deselectAnnotation:annotation animated:YES];
}
}];
[alerController addAction:action];
[alerController addAction:action1];
[alerController addAction:action2];
[self.navigationController presentViewController:alerController animated:YES completion:nil];
}