场景:
在处理Marker点击事件时,此时地图上有Marker点A及Marker点B,当选中Marker点A后,SDK方法
"didSelectAnnotationView"响应了点击事件,并进行了对应的逻辑处理(我在此进行了弹窗操作).
当关闭弹窗想再次选中Marker点A,此时"didSelectAnnotationView"不再响应.需选中Maker点B
后方法才会再次响应.也就是说当连续选中同一个Marker点时会导致"didSelectAnnotationView"
出现不响应的情况.
方案一:

///如果已经是选中状态,再次点击不会触发此回调。取消选中需调用
-(void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view{
[mapView deselectAnnotation:view.annotation animated:YES];
}
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation
{
// [self.aOverlays addObject:annotation];
if ([annotation isKindOfClass:[MAUserLocation class]]) {
NSLog(@"用户定位点");
if (self.startCoordinate.latitude == ) {
// [self requestData:((MAUserLocation *)annotation).location.coordinate filed:@"priority"];
self.startCoordinate = ((MAUserLocation *)annotation).location.coordinate;
self.filed = @"";//priority
[self loadData];
}
self.startCoordinate = ((MAUserLocation *)annotation).location.coordinate; return nil;
}
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;
//
case MANaviAnnotationTypeWalking:
[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;
} return annotationView; }
return nil;
}
方案二:
针对上述问题,可在创建Annotationview时给这个Annotationview添加Tap手势
自己对事件进行处理不依赖SDK提供的方法
/**
* @brief 根据anntation生成对应的View(设置标准样式)
* @param mapView 地图View
* @param annotation 指定的标注
* @return 生成的标注View
*/
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation
{
if ([annotation isKindOfClass:[MAPointAnnotation class]])
{
static NSString *pointDefaultIndentifier = @"pointDefaultIndentifier";
AnnotationViewManager *annotationView = (AnnotationViewManager *)[mapView dequeueReusableAnnotationViewWithIdentifier:pointDefaultIndentifier];
if (annotationView == nil)
{
annotationView = [[AnnotationViewManager alloc] initWithAnnotation:annotation reuseIdentifier:pointDefaultIndentifier];
// 给Marker点添加手势
[annotationView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onMarkerClick:)]];
}
annotationView.centerOffset = CGPointMake(, -);
annotationView.image = [UIImage imageNamed:@"map_tubiao_zuche_icon"];
return annotationView;
}
return nil;
}
// Marker选中事件
- (void)onMarkerClick:(UITapGestureRecognizer *)gesture
{
// 这里做你想的事情
MAAnnotationView *annoView = (MAAnnotationView*)gesture.view;
NSLog(@"选中了: %@",annoView.annotation.title); // 解决5.0.0上Annotation选中后重用的bug.
if(annoView.annotation == self.mapView.selectedAnnotations.firstObject)
{
if(annoView.selected == NO)
{
[annoView setSelected:YES animated:YES];
}
return;
}
else
{
[self.mapView selectAnnotation:annoView.annotation animated:YES];
}
}

iOS - 集成高德SDK解决Marker点重复点击无效问题的更多相关文章

  1. iOS - (集成支付宝SDK大坑总结)

    其实集成支付宝相对于集成微信支付来说,支付宝算是简单的了,后续有空再去研究微信支付,现目前先总结一下集成支付宝所遇到的坑,其实支付宝的坑也不算太多,细算下来大概5-6个左右,但是其报错方式有点恶心,不 ...

  2. iOS通用链接(Universal Links)突然点击无效的解决方案

    接上文<微信中通过页面(H5)直接打开本地app的解决方案>已经把iOS搞定并且已经正常能跑了,突然就再也用不了了... 问题描述 测试告诉我,如果从微信打开App之后,点击App右上角的 ...

  3. 解决jquery zclip 插件点击无效的问题

    使用jquery zclip 用于页面复制文本内容. 首先引入js <script type="text/javascript" src="../js/jquery ...

  4. iOS 集成百度地图 位置偏移问题

    iOS 集成百度SDK 请参考 百度地图官方文档 ,这里不就多啰嗦了 本文介绍的是在百度地图上根据经纬度,自定义气泡时,气泡位置的偏移,在我们天朝这种事是很常见的,也见怪不怪了,在项目中使用的百度地图 ...

  5. 李洪强iOS之集成极光推送三iOS集成指南

    李洪强iOS之集成极光推送三iOS集成指南 SDK说明 适用版本 本文匹配的 SDK版本:r2.1.5 以后.查看最近更新了解最新的SDK更新情况.使用Xcode 6及以上版本可以使用新版Push S ...

  6. iOS之防止用户重复点击Button(按钮)问题

    在项目中,我们往往会遇到这样的问题:因为网络较慢的原因,用户会不耐烦的一直去点击按钮,这样导致的结果时:相关代码一遍一遍的被重复执行,如果按钮的事件是网络请求的话,这样又导致一种网络请求的循环.所以我 ...

  7. 手把手教你搞定个推iOS推送SDK集成

    以下是一位开发者在集成个推iOS推送SDK过程中的真实经历. 作者:Ezreallp 一次偶然的机会,公司的项目要用到推送,我自己本来就很懒,不愿意去弄整套APNS的流程,刚好之前跟朋友聊起过他们的产 ...

  8. iOS小技巧:用runtime 解决UIButton 重复点击问题

    http://www.cocoachina.com/ios/20150911/13260.html 作者:uxyheaven 授权本站转载. 什么是这个问题 我们的按钮是点击一次响应一次, 即使频繁的 ...

  9. Android集成高德地图如何自定义marker

    高德地图自定义Marker 高德地图默认的marker样式是这种 一般的修改样式是通过icon接口来调整 MarkerOptions markerOptions = new MarkerOptions ...

随机推荐

  1. embOS ARM and Cortex Library Object and Symbol List

    OS_Alloc.o OS_free OS_Alloc.o OS_malloc OS_Alloc.o OS_realloc OS_ARM720_MMU.o OS_ARM720_CACHE_CleanR ...

  2. hadoop2.7.3编译,支持snappy、bzip2本地压缩

    软件包: apache-ant-1.9.9-bin.tar.gz apache-maven-3.3.9-bin.tar.gz apache-tomcat-6.0.44.tar.gz CentOS-6. ...

  3. 关于EOF的使用的好文章

    Linux shell脚本EOF妙用 https://blog.csdn.net/zongshi1992/article/details/71693045

  4. 命令行:增强版 | Linux 中国

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/F8qG7f9YD02Pe/article/details/83542677 以下就是我如今使用的用于 ...

  5. 浪院长 | spark streaming的使用心得

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/rlnLo2pNEfx9c/article/details/82505159 今天.主要想聊聊spar ...

  6. 使用python实现深度神经网络 3(转)

    使用python实现深度神经网络 3 快速计算梯度的魔法--反向传播算法 快速计算梯度的魔法--反向传播算法 一.实验介绍 1.1 实验内容 第一次实验最后我们说了,我们已经学习了深度学习中的模型mo ...

  7. Android 获取Activity当前view

    View cv = getWindow().getDecorView(); 来自为知笔记(Wiz)

  8. [Java] zjdbcping:JDBC数据库连接测试工具

    作者: zyl910 一.缘由 当数据库服务器很多时,或者要与第三方公司做数据库表交换时,此时觉得若有一个简单快捷的数据库连接测试工具就好了. 因为若是采取直接把程序部署到tomcat等容器再测试的办 ...

  9. Ubuntu18.04下的模拟神器RetroArch

    安装 直接通过apt安装 sudo add-apt-repository ppa:libretro/stable sudo apt update sudo apt install retroarch ...

  10. Android获取通讯录并上传(包含通讯录加密)

    好久没更新文章了,近期在做通讯录上传,把它分享出来,送给需要的朋友. 写了一个通讯录工具类,直接放代码吧,关键位置通过注释来解释. 这个工具类包含通讯录获取,加密,然后上传操作.看不懂的可以留言 im ...