问题描述
- IOS 百度地图 标注删除不了?求求大神啊 拜托了
-
if (!_perList) {
_perList=[[PersonalViewController alloc]init];
[self becomeFirstResponder];
CGFloat y=CGRectGetMaxY(_toolBar.frame);
CGRect popFrame=CGRectMake(10, y, self.view.frame.size.width-20, self.view.frame.size.height-y-10);
_perList.view.frame=popFrame;
}
__unsafe_unretained PhLocationViewController*mapVC=self;
__unsafe_unretained PersonalViewController *per=_perList;
__block PhLocationViewController *blockSelf = self;
[_perList setSelectedBlock:^(NSString *name,NSString *uid)
{
[AlertHelper MBHUDShow:@"获取中" ForView:blockSelf.view AndDelayHid:30];
[per.view removeFromSuperview];
[phoneLocationWebAPI getUserInMapWithTpe:@"one" uid:uid stime:@"" etime:@"" success:^(NSArray *locList)
{
[mapVC->_mapView removeAnnotations:mapVC->_annoArr];if (locList.count==0) { [AlertHelper hideAllHUDsForView:blockSelf.view]; [AlertHelper singleMBHUDShow:@"无定位数据" ForView:blockSelf.view AndDelayHid:1.5]; return ; } Employee *em1=[[Employee alloc]initWithDic:locList[0]]; CLLocationCoordinate2D dingweiZhongxin=CLLocationCoordinate2DMake([em1.latitude doubleValue], [em1.longitude doubleValue]); [mapVC showMap:CLLocationCoordinate2DMake(dingweiZhongxin.latitude, dingweiZhongxin.longitude) span:BMKCoordinateSpanMake(0.01, 0.01)];; for (NSDictionary *dict in locList) { Employee *em=[[Employee alloc]initWithDic:dict]; CLGeocoder *geocoder=[[CLGeocoder alloc]init]; CLLocationCoordinate2D loca2D=CLLocationCoordinate2DMake([em.latitude doubleValue], [em.longitude doubleValue]); CLLocation *la=[[CLLocation alloc]initWithLatitude:loca2D.latitude longitude:loca2D.longitude]; [geocoder reverseGeocodeLocation: la completionHandler:^(NSArray *placemark,NSError *error) { CLPlacemark *mark=[placemark objectAtIndex:0]; NSString *address = [NSString stringWithFormat:@"%@",mark.name]; BMKPointAnnotation *point=[[BMKPointAnnotation alloc]init]; point.coordinate=loca2D; point.title=[NSString stringWithFormat:@"%@ 状态:%@,%@",em.userName,([@"1" isEqualToString: em.zt ])?@"在线":@"离线",em.time]; point.subtitle=address; [mapVC->_annoArr addObject:point]; [mapVC->_mapView addAnnotations:mapVC->_annoArr]; }]; } [AlertHelper hideAllHUDsForView:blockSelf.view]; } fail:^(){ [AlertHelper hideAllHUDsForView:blockSelf.view]; [AlertHelper singleMBHUDShow:@"网络请求失败" ForView:blockSelf.view AndDelayHid:1.5]; }]; }]; [self changeBtnSelected:sender popView:_perList.view];
为啥会出现旧的标注 这样写有什么问题啊
解决方案
iOS 自定义百度地图标注气泡
iOS 之 使用百度地图 (删除地图页面所有自己添加的标注)
时间: 2024-11-03 14:15:44