I am a Mobile application developer working in Madrid ✨✨.
- 🔭 I’m currently working at Kairos Digital Solutions
- ⚙️ I use daily:
.swift
,.ObjC
.
connect with me here:
HACClusterMapViewController class is written in Objective-C and facilitates the use of maps when they have many pins that show.
License: MIT License
Individual pins are not showing up when the coordinates are too near adn zoomed in to maximum level, instead showing cluster count
Sample Data:
@{kLatitude:@48.47352, kLongitude:@3.87426, kTitle : @"Title 1", kSubtitle : @"", kIndex : @0},
@{kLatitude:@52.59758, kLongitude:@-1.93061, kTitle : @"Title 2", kSubtitle : @"Subtitle 2", kIndex : @1},
@{kLatitude:@48.47352, kLongitude:@3.87425, kTitle : @"Title 3", kSubtitle : @"Subtitle 3", kIndex : @2},
@{kLatitude:@48.31921, kLongitude:@18.10184, kTitle : @"Title 4", kSubtitle : @"Subtitle 4", kIndex : @3},
@{kLatitude:@47.84302, kLongitude:@22.81101, kTitle : @"Title 5", kSubtitle : @"Subtitle 5", kIndex : @4},
@{kLatitude:@60.88622, kLongitude:@26.83792, kTitle : @"Title 6", kSubtitle : @"" , kIndex : @5}
];
Hi,
The map gets loaded but the annotations are not visible until there is a touch on the mapView. Please have a look. And also the annotations images have a black color on their background(iOS 11.0). One problem is also there as the pins not hide proper, they shown after the cluster formation. Please see the attached screenshot.
When i slide the mapView,sometimes catch the error:
malloc: *** error for object 0x7fd68d60b848: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug
@litoarias I hope you can solve this problem, tanks.
Hi ,
I added this library into my project via cocoapods pod 'HACClusterMapViewController' but from some reason i get a version where didDeselectAnnotationView is not working..
i investigated it a bit and found that the following line of code:
if ([view isKindOfClass:[HAClusterAnnotation class]]){
need to be replaced with
if ([view.annotation isKindOfClass:[HAClusterAnnotation class]]){
a temporary workaround (for those who want to use cocoapods) is to put the following line in your podfile
pod 'HACClusterMapViewController' , :git => 'https://github.com/litoarias/HACClusterMapViewController.git'
Thanks,
Ran.
Hello,
First of all, a big thank you to you for this lib !
I've noticed a memory leak in the function buildTreeWithArray in HACManagerQuadTree.m:
I made these changes and no memory leak anymore.
It's the same thing for the function buildTreeWithExample
I simply added this:
free(dataArray);
dataArray = NULL;
and change the function malloc to calloc (not necessary but useful in our case, no need to multiply explicitly).
Hi, I have problem with displaying special characters, such as "ě,š,č,ř,ž,ý,á,í" etc in annotation info on top of annotation. Is there some solution to fix that? Thank you!
In the MapViewController regionDidChangeAnimated: calls self.bounds outside of the main thread. This causes warnings/errors during runtime from the main thread checker in XCode 9.
The operation queue should not be a new queue, but the main queue.
The didSelectAnnotationView method from HACMKMapViewDelegate protocol does not work, but when I change this
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(HAClusterAnnotation *)view{
if ([view isKindOfClass:[HAClusterAnnotation class]]){
HAClusterAnnotation *annotation = (HAClusterAnnotation *)view;
to
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
if ([view.annotation isKindOfClass:[HAClusterAnnotation class]]){
HAClusterAnnotation *annotation = (HAClusterAnnotation *)view.annotation;
it works fine.
I used this library to implement my mapview. But I needed an extra customization in it. An image view inside each pin. So I edited accordingly.
In HAClusterAnnotation.h I have added
@property (nonatomic,strong) UIImageView *imageProfileView;
In HACMKMapView.m
I have added the imageview as addSubView in annotationView
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if (![annotation isKindOfClass:[HAClusterAnnotation class]])
return nil;
static NSString *const HACAnnotatioViewReuseID = @"HACAnnotatioViewReuseID";
HAClusterAnnotationView *annotationView = (HAClusterAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:HACAnnotatioViewReuseID];
UIColor * fillColor= Nil;
if (!annotationView) {
if (self.mapDelegate && [self.mapDelegate respondsToSelector:@selector(fillColorForAnnotation:)]) {
fillColor = [self.mapDelegate fillColorForAnnotation:annotation];
}
if (!fillColor) {
fillColor= self.backgroundAnnotation;
}
annotationView = [[HAClusterAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:HACAnnotatioViewReuseID borderColor:self.borderAnnotation backgroundColor:fillColor textColor:self.textAnnotation];
}else{
if (self.mapDelegate && [self.mapDelegate respondsToSelector:@selector(fillColorForAnnotation:)]) {
fillColor = [self.mapDelegate fillColorForAnnotation:annotation];
}
if (!fillColor) {
fillColor= self.backgroundAnnotation;
}
annotationView.circleBackgroundColor = fillColor;
}
annotationView.circleBorderColor = self.borderAnnotation;
annotationView.circleTextColor = self.textAnnotation;
annotationView.count = [(HAClusterAnnotation *)annotation count];
annotationView.canShowCallout = YES;
if (annotationView.count == 1) {
annotationView.imageProfileView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 4, 20, 20)];
[annotationView addSubview:annotationView.imageProfileView];
if (self.mapDelegate && [self.mapDelegate respondsToSelector:@selector(viewForAnnotationView:annotation:)]) {
[self.mapDelegate viewForAnnotationView:annotationView annotation:annotation];
}else{
annotationView.image = self.defaultImage;
}
annotationView.centerOffset = CGPointMake(0,-annotationView.frame.size.height*0.5);
}else{
if (self.mapDelegate && [self.mapDelegate respondsToSelector:@selector(viewForAnnotationView:clusteredAnnotation:)]) {
[self.mapDelegate viewForAnnotationView:annotationView clusteredAnnotation:annotation];
}
}
[annotationView setNeedsLayout];
return annotationView;
}
Finally, I assigned a static image in imageProfileView
-(void)viewForAnnotationView:(HAClusterAnnotationView *)annotationView annotation:(HAClusterAnnotation *)annotation{
if (annotation.index % 2 == 0) {
if (annotation.index == 2) {
annotationView.canShowCallout = NO;
}
annotationView.image = [UIImage imageNamed:@"pin_museum"];
}else{
annotationView.image = [UIImage imageNamed:@"pin_coffee"];
}
annotationView.imageProfileView.image = [UIImage imageNamed:@"user_icon"];
annotationView.imageProfileView.layer.cornerRadius = 20/2.0;
annotationView.imageProfileView.layer.masksToBounds = YES;
}
Initially, when I zoom in its shows a perfect pin with a image in it. But sometimes,when I zoom out or in the Profile image is placed outside the pins. You will better understand if you look at the attached screenshots. It will be very helpful if you help me out.
It is not dropping any pin even after providing all required coordinates.
the app crashes if I use
NSArray *data = @[
@{kLatitude:@48.47352, kLongitude:@3.87426, kTitle : @"Title 1", kSubtitle : @"", kIndex : @0},
@{kLatitude:@52.59758, kLongitude:@-1.93061, kTitle : @"Title 2", kSubtitle : @"Subtitle 2", kIndex : @1},
@{kLatitude:@48.41370, kLongitude:@3.43531, kTitle : @"Title 3", kSubtitle : @"Subtitle 3", kIndex : @2},
@{kLatitude:@48.31921, kLongitude:@18.10184, kTitle : @"Title 4", kSubtitle : @"Subtitle 4", kIndex : @3}];
[self.mapView.coordinateQuadTree buildTreeWithArray:data];
other than viewDidLoad and viewWillAppear. I have declared it in viewDidAppear and I got EXC_BAD_ACCESS on this line if (!HACBoundingBoxIntersectsBoundingBox(node->boundingBox, range))
in void HACQuadTreeGatherDataInRange(HACQuadTreeNode* node, HACBoundingBox range, HACDataReturnBlock block)
method.
Now in my case I need to insert data in buildTreeWithArray after I get my current location. So thats not happening here. This method getting fired before annotation data initalization - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
. Please fix this.
`
not work
The podspec file is still pointing to 2.4 instead of 2.6.2
This causes irritations when adding the pod into local project. regarding versioning.
In Italy in the address field it is almost always present "," it is but 'used as a key field to create various fields including the index.
This method:
-(NSArray *)dropPinsWithData:(NSArray )data {
NSMutableArrayannotationArray= [NSMutableArray new];
for (int i = 0; i < data.count; i++) {
NSDictionary *d = data[i];
NSMutableString *line = [NSMutableString new];
[line appendString:[NSString stringWithFormat:@"%@, ", [d valueForKey:kLongitude]]];
[line appendString:[NSString stringWithFormat:@"%@, ", [d valueForKey:kLatitude]]];
[line appendString:[NSString stringWithFormat:@"%@, ", [d valueForKey:kTitle]]];
[line appendString:[NSString stringWithFormat:@"%@, ", [d valueForKey:kIndex]]];
[line appendString:[NSString stringWithFormat:@"%@", [d valueForKey:kSubtitle]]];
[annotationArray addObject:line];
}
Add "," for separated string used by
HACQuadTreeNodeData HACDataFromLine(NSString *line)
{
NSArray *components = [line componentsSeparatedByString:@","];
In the subtitle field, putting an address like: "Corso Italy, 47"
This generates an error in the calculation of the various fields.
Currently I replaced the "," with the "|" to be used as a separator in the 2 methods mentioned above
Hi,
I have some issue with color references for not being retained.
This causes access violations during runtime as ARC drops the UIColor objects.
(Happens under iOS 10.3.1, iPad Air2 and iPhone6)
- HACClusterAnnotationView.h: circleBackgroundColor, circleBorderColor, circleTextColor
- HACClusterAnnotation.h: fillColor
Those properties should be "retain
", not "assign
".
Crashes occured in HACClusterAnnotationView.m , "drawRect"
. Here it happens that you have dangling references.
Regards,
Oggerschummer
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.