场景:
在处理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. RequireJs 的 使用

    为什么使用requirejs: 1.有效的防止命名的冲突 2.声明不同js之间的依赖 3.可以让我们的代码以模块化的方式组织 用法: 1.创建一个入口文件main.js(自己随便命名) 然后引入req ...

  2. 【状压dp】Trie 树 @中山纪念中学20170304

    目录 Trie 树 PROBLEM 题目描述 输入 输出 样例输入 样例输出 SOLUTION CODE Trie 树 PROBLEM 题目描述 字母(Trie)树是一个表示一个字符串集合中所有字符串 ...

  3. 咏南APP(手机)开发框架

    咏南APP(手机)开发框架 有意者可向咏南索取DEMO. 基于DELPHI官方的FIREMONKEY类库构建,不使用任何三方控件. 原生手机框架,支持各种手机硬件操作. 主界面 聊天 照相并分享 短信 ...

  4. java 使用CXF将wsdl文件生成客户端代码命令java调用第三方的webservice应用实例

    1.先下载cxf包https://download.csdn.net/download/suizhikuo/108112362.解压缩包,通过cmd命令进入到bin目录下(cd cxf\bin的路径) ...

  5. JavaScript单独的模块中传递数据

    首先我们来看看这张图,让我们来思考一下! 下买我给出我的完整思路代码 html代码: <!DOCTYPE html> <html lang="zh-CN"> ...

  6. ld: framework not found FileProvider for architecture arm64

    出现这个问题是因为  静态库是用Xcode9打包的. 如果用xcode8编译的话就会出现这个问题 解决办法 从Xcode9里把这个库拷贝出来.然后放到Xcode8上面 One way to fix t ...

  7. JSP简单练习-猜字母游戏

    <!-- guessCharExample.jsp --> <%@ page contentType="text/html; charset=gb2312" %& ...

  8. 在Centos7下安装nghttp2

    如果是Ubuntu18.04, 系统本身已经带了nghttp2了, 直接apt安装就可以. 下载源代码 https://github.com/nghttp2/nghttp2 如果是在Ubuntu下编译 ...

  9. 朗科32G TF卡的读写测试

    卡是这样的, 下面是实际测试的结果. 容量测试 SKS的USB2外置读卡器, X240内置读卡器加上SD卡套    UNITEK的USB3.0读卡器, 经过UNITEK的USB3.0 HUB 看来读4 ...

  10. Asp.net的HttpContext.Current.Items详解

    之前asp.net只是在使用Session来进行用户会话时的信息存储,甚至很少留意Session完整的类调用是HttpContext.Current.Sessoin.... 好吧,我还是处于只会固定写 ...