选中回填 高德_iOS - 集成高德SDK解决Marker点重复点击无效问题

本文介绍了在iOS应用中集成高德SDK时,如何处理Marker点重复点击无效的问题。通过监听`didSelectAnnotationView`回调,并在`viewForAnnotation`方法中设置自定义的Annotation View,确保每次点击都能触发正确的行为。
摘要由CSDN通过智能技术生成

方案一:///如果已经是选中状态,再次点击不会触发此回调。取消选中需调用

-(void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view{

[mapView deselectAnnotation:view.annotation animated:YES];

}- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation

{//[self.aOverlays addObject:annotation];

if ([annotation isKindOfClass:[MAUserLocation class]]) {

NSLog(@"用户定位点");if (self.startCoordinate.latitude == 0) {//[self requestData:((MAUserLocation *)annotation).location.coordinate filed:@"priority"];

self.startCoordinate = ((MAUserLocation *)annotation).location.coordinate;

self.filed= @"2";//priority

[self loadData];

}

self.startCoordinate= ((MAUserLocation *)annotation).location.coordinate;returnnil;

}if ([annotation isKindOfClass:[MAPointAnnotation class]])

{static NSString *customReuseIndetifier = @"customReuseIndetifier";

SDCustomAnnotationView*annotationView = (SDCustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:customReuseIndetifier];if (annotationView ==nil)

{

annotationView=[[SDCustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:customReuseIndetifier];

}

kWeakSelf(self);

annotationView.secletAnnotation= ^{

NSInteger row=[weakself.annotations indexOfObject:annotation];

NSLog(@"点击了---->%ld",(long)row);

};

annotationView.canShowCallout=YES;

annotationView.image=nil;if ([annotation isKindOfClass:[MANaviAnnotation class]])

{switch (((MANaviAnnotation*)annotation).type)

{//case MANaviAnnotationTypeRailway://poiAnnotationView.image = [UIImage imageNamed:@"railway_station"];//break;//

//case MANaviAnnotationTypeBus://poiAnnotationView.image = [UIImage imageNamed:@"bus"];//break;//

//case MANaviAnnotationTypeDrive://poiAnnotationView.image = [UIImage imageNamed:@"car"];//break;// caseMANaviAnnotationTypeWalking:

[self.aOverlays addObject:annotation];

annotationView.image= [UIImage imageNamed:@"man_map"];break;//case MANaviAnnotationTypeRiding://poiAnnotationView.image = [UIImage imageNamed:@"ride"];//break;// default:break;

}

}else{

annotationView.image= [UIImage imageNamed:@"addr_map"];

annotationView.count=annotation.subtitle;

}returnannotationView;

}returnnil;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值