GithubHelp home page GithubHelp logo

gunterhager / annotationclustering Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 3.0 907 KB

Framework that clusters annotations on MKMapView. (Deprecated)

License: MIT License

Objective-C 13.68% Swift 19.74% C 0.19% Makefile 66.40%

annotationclustering's People

Contributors

gunterhager avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

annotationclustering's Issues

How to remove annotations from cluster?

Hi!

Really cool clustering you have implemented. However, I'm looking for a way to remove all annotations from the cluster before I add new ones in order to avoid duplicates.

I tried to implement this by adding this in QuadTree.swift

func removeAllAnnotations(){
        rootNode.removeAllAnnotations()
    }

And this seems to work... kinda, but not if I call it when adding annotations.

 public func addAnnotations(annotations:[MKAnnotation]) {
        lock.lock()
        removeAllAnnotations()
        for annotation in annotations {
            tree.addAnnotation(annotation)
        }
        lock.unlock()
    }

    func removeAllAnnotations(){
        tree.removeAllAnnotations()
    }

I still get duplicates this way. And even if I add the removeAllAnnotations() call to after the tree.addAnnotation(annotation) call I still get plenty of annotations in my map.

Any idea how to best implement this? I basically just want to remove all clustered annotations before adding new ones.

Add `removeAnnotation` to QuadTree

removeAnnotation would find the given annotation leaf in the quadtree and remove it.

This would make it possible to

  1. remove annotations from the quadtree
  2. replace annotations in the quadtree (i.e. for moving map objects) via subsequent calls to removeAnnotation & addAnnotation

Odd reaction with cluster more than 1K Annotation with the same Latitude and Longitude.

I have problem when trying to add same coordinates many time but in example show only 440 cluster.
To re produce the bug :
in Example/ViewController.swift
line 29: let numberOfLocations = 1000
line 52: a.coordinate = CLLocationCoordinate2D(latitude: 15.415599822998047, longitude: 101.57099914550781)

and then compile and run.

the map show only 440 annotation
simulator screen shot jun 13 2016 2 22 08 pm

AnnotationClusterViewOptions does not have any effect

Hi, this is a really nice plugin. Everything seems to work except for the AnnotationClusterViewOptions. The code below worked back when i used the FBAnnotationClusteringSwift but can't figure out why it isn't working here.

Here's a snippet from my viewForAnnotation method that handles the annotation cluster

case let cluster as AnnotationCluster:
reuseId = "Cluster"
if let clusterView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? AnnotationClusterView {
    clusterView.reuseWithAnnotation(cluster)
    return clusterView
} else {
    let options = AnnotationClusterViewOptions(smallClusterImage: "cluster_small", mediumClusterImage: "cluster_medium", largeClusterImage: "cluster_large")
    let clusterView = AnnotationClusterView(annotation: cluster, reuseIdentifier: reuseId, options: options)
    return clusterView
}

Thanks!

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.