Coder Social home page Coder Social logo

litoarias / hacclustermapviewcontroller Goto Github PK

View Code? Open in Web Editor NEW
187.0 187.0 31.0 5.9 MB

HACClusterMapViewController class is written in Objective-C and facilitates the use of maps when they have many pins that show.

License: MIT License

Objective-C 97.75% Ruby 2.25%

hacclustermapviewcontroller's Introduction

Hi there 👋

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:

LinkedIn Badge Medium Badge

Github Public Stats

My Github Stats

visitor badge

hacclustermapviewcontroller's People

Contributors

drodrigueiecisa avatar litoarias avatar oggerschummer avatar sbelmeha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hacclustermapviewcontroller's Issues

annotation.index wrong if in the title or subtitle is a ","

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 {
NSMutableArray
annotationArray= [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

Clustering issue

Individual pins are not showing up when the coordinates are too near and zoomed into maximum level, instead showing cluster count.

I know it was posted earlier as an issue by phaneendrakv and also closed. But I'm facing the same problem again. Is it possible to fix?
screen

Special characters in annotation info box

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!

Not called didSelectAnnotationView

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.

Memory leak detected in buildTreeWithArray function

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:

capture d ecran 2015-12-03 a 11 27 35
capture d ecran 2015-12-03 a 11 27 46

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).
capture d ecran 2015-12-03 a 11 28 47

Can't render a imageview properly while zooming in and out

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.

1_zoom_in
2_zoom_out

Color references not retained

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

view.bounds called on background view

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.

  • (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
    [[NSOperationQueue new] addOperationWithBlock:^{
    double scale = self.bounds.size.width / self.visibleMapRect.size.width;
    NSArray *annotations = [self.coordinateQuadTree clusteredAnnotationsWithinMapRect:mapView.visibleMapRect withZoomScale:scale];
    //TODO: Avoid removing non clustered annotation
    [self updateMapViewAnnotationsWithAnnotations:annotations];
    }];
    }

app crashes if the data is not loaded in viewDidLoad

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.

`

Annotations not shows without touch on device.

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.
image-1

malloc: *** error for object

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.

Problem using with swift

I do not know how to describe this, but what happen is, I cannot get cluster to show up, so I decide to debug and wha happen is that it cannot get any value in Line 21 and 22. please check the photo
screen shot 2016-06-06 at 11 14 06 am

Cluster issue

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}
];
screen shot 2016-01-13 at 1 17 44 pm

Integration issue

It is not dropping any pin even after providing all required coordinates.

didDeselectAnnotationView not working when using cocoapods

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.