场景:
在处理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. JAVA自学笔记22

    JAVA自学笔记22 1.操作基本数据类型的流 DataInputStream DataOutputStream 数据输出流允许应用程序以适当方式将基本的Java数据类型写入输出流中.然后,应用程序可 ...

  2. windows NT的意义和各个版本

    javascript中navigator.userAgent里的window NT今天为了尝试查看网址的来源document.referrer,但是不知道每个浏览器的版本号,然后我就用navigato ...

  3. jeffy-vim-v3.1.tar.gz

    下载链接: https://files.cnblogs.com/files/pengdonglin137/jeffy-vim-v3.1.tar.gz 1. 使用sublimemonokai配色 2. ...

  4. cocos creator热更新教程

    1.下载HotUpdate热更新DEMO 2.在cocos creator中下载热更新插件,cocos creator版本要在1.7及以上版本 3.插件默认安装在C:\Users\Administra ...

  5. 开发入门,学Java还是学大数据?

    经常有人问,我想学习开发,到底是学Java好还是学大数据好?或者是,学习大数据还有必要学Java吗?      依我说,这个提问的标准答案是:两者都学.      先来甩两张图.      一张是腾讯 ...

  6. Android: Android Studio签名打包的两种方式(zz)

    注:给我们自己开发的app签名,就代表着我自己的版权,以后要进行升级,也必须要使用相同的签名才行.签名就代表着自己的身份(即keystore),多个app可以使用同一个签名. 如果不知道签名是啥意思, ...

  7. 关于 Docker Hub 上不能注册 Docker ID 的问题

    1. 引言 我们中国大陆访问dockerhub的时候,想要注册一个dockerID,发现sign up按钮是灰色的,不能点击进行注册.这个时候通过点击右键"查看网页源代码"和&qu ...

  8. 【20180409】IT管理之IT十二条令

    团队越来越大,靠人管几乎有力无心,只能靠制度管理了. 前段时间对部门颁布了12条令,效果明显. 特此Mark. 汇报: 三条总结:汇报讲究精简,一个事情最多一句话概括. 一页报告:内容精简,报告一页w ...

  9. Android 源码学习

    工具篇:如何使用 Visual Studio Code 阅读 Android 源码:https://jekton.github.io/2018/05/11/how-to-read-android-so ...

  10. MyBatis3 入门学习指南

    官网原文:http://www.mybatis.org/mybatis-3/zh/index.html 1.简介 1.1 什么是 MyBatis? MyBatis 是一款优秀的持久层框架,它支持定制化 ...