高德地图聚合
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高德地图聚合相关的知识,希望对你有一定的参考价值。
使用git做版本控制
步骤如下:
下载,拖进来.a
拷贝算法文件
拷贝SDDemandListViewController
根据报错修改相应文件
添加方法 makeContent
添加属性@property (nonatomic, strong) NSNumber *category; //任务分类 sven添加
拖进来图片资源搞定
------------------------------------------------------------------------
bug
---------------------------------------------------------------------------
高德地图聚合
- (void)mapView:(MAMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
// We add a new operation queue to do the clustering
[[NSOperationQueue new] addOperationWithBlock:^{
double scale = self.mapView.bounds.size.width / self.mapView.visibleMapRect.size.width;
NSArray *annotations = [self.clusteringManager clusteredAnnotationsWithinMapRect:mapView.visibleMapRect withZoomScale:scale];
// The clusteringManager will get the main queue to do the UI stuff.
[self.clusteringManager displayAnnotations:annotations onMapView:mapView];
}];
} // 加上之后不显示大头针了,annotations为空
------------------------------------------------------------------------------------------------------------
点击任务详情崩溃
添加下面代码就好了
SDResourceQueryMode *content = [self.contentData objectAtIndex:[annotation.title integerValue]];
[annotationView makeContent:content WithCustomAnnotationViewClick:^(NSString *resourceID) {
NSString *userID = [NSString stringWithFormat:@"%@",content.mUserId];
SDDemandReceiveViewController *demandDetail = \
[[SDDemandReceiveViewController alloc] initWithResourceID:resourceID WithUserID:userID];
demandDetail.forwardVC = @"mainOrTask";
[self.navigationController pushViewController:demandDetail animated:YES];
}];
------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -------
// 下面的方法不调用
NSArray *annotations = [self.clusteringManager clusteredAnnotationsWithinMapRect:mapView.visibleMapRect withZoomScale:1]; // 没有获取到大头针 scale
NSLog(@"annotations.count%td",annotations.count); // 不调用这个方法
---------------------------------------------------------------------------------------------------------
双击就行了
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
点击图片跳转到弹出黑色view
------------------------------------------------------------------------------------------------------------------------
点击图片不能弹出黑色View
点击后方法不走,被拦截了? 初始化的时候加上手势就不行了 在适当的位置加下面的代码
self.portraitImageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jump)];
[self.portraitImageView addGestureRecognizer:tap];
return;
你是如何知道在哪里加这些代码的? 注释掉一部分,再打开一部分
第一次点击没有跳转,第二次点击才跳转,在设置下标数字的时候添加手势
- (void)setCount:(NSUInteger)count
{
_count = count;
self.clusterLbl.backgroundColor = [UIColor redColor];
self.clusterLbl.text = [@(_count) stringValue];
self.clusterLbl.textAlignment = NSTextAlignmentCenter;
self.clusterLbl.font = [UIFont systemFontOfSize:15];
self.clusterLbl.textColor = [UIColor whiteColor];
self.portraitImageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jump)];
[self.portraitImageView addGestureRecognizer:tap];
}
----------------------------
拿不到数组,写懒加载就行了,如果不为空直接走掉.打断点,看数组元素的个数,发现的
----------------------------
图片崩溃,数组内容不对,没有获取到正确的模型
如何知道是哪几个聚合了,拿不到模型
如何拿到聚合后的模型
可以知道聚合后的模型数量,如何获得contentData 搞定
for ( MAPointAnnotation *pointAnnotation in ((MAAnnotationCluster *)annotation).annotations) {
SDResourceQueryMode *content = [self.contentData objectAtIndex:pointAnnotation.title.intValue];
[contentArr addObject:content];
}
------------------------------------------------------------------------------------
点击cell push到新控制器
------------------------------------------------------------------------------------
Bug:聚合不太灵敏
以上是关于高德地图聚合的主要内容,如果未能解决你的问题,请参考以下文章