Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No clusters or pins displayed when zoomed out #116

Closed
smahmoodpbm opened this issue Feb 2, 2016 · 9 comments
Closed

No clusters or pins displayed when zoomed out #116

smahmoodpbm opened this issue Feb 2, 2016 · 9 comments
Labels

Comments

@smahmoodpbm
Copy link

Issue: when viewing clusters over the international dateline clusters and pins disappear. This issue can be recreated with the following steps:

  1. Add annotations which cluster across the world.
  2. Move the mapview over the international date line (see images below). If the user moves over the dateline and reloads new annotations, no clusters are displayed.

map-pins
map-nopins

@smahmoodpbm
Copy link
Author

To recreate the issue I have attached a test project:

Three buttons have been created to show the problem:

Button:
"Data Loads Correctly": Positions the map to an area which will load the data correctly. After tapping this button tap "Load Data" to show the clusters appearing.
"All Data Does Not Load": positions the map to show the data not loading correctly. After tapping this button tap "Load Data" to show all clusters not appearing.

Tapping Load Data will load the data once the map is positioned (regardless of where you position).

kingpin-test.zip

@stanislaw
Copy link
Collaborator

@smahmoodpbm

thanks for reporting this!

I was able to reproduce this issue using your test project. The problem was in annotation tree that was not recognizing MKMapRect spanned over international dateline. Quick fix I have made just checks for this case and splits spanning map rect into two parts.

Before fixing it in actual kingpin I want to know if my fix solves your original issue.

https://github.com/stanislaw/Examples/tree/20160210-kingpin-international-dateline

@smahmoodpbm
Copy link
Author

Thanks Stainislaw, great work! The changes do help it looks like the pins now appear however I noticed the clustering count value seems to be off (this may be related to state of the fix). For example taking a look at north america counts vs. counts you get when positioning over the date line.

Thanks for helping!
count-display

@stanislaw
Copy link
Collaborator

Maybe I am missing something on your screenshots but looks like it is expected behavior of kingpin -- when you press "Load Data" multiple times on the same screen (without moving/zooming it) you will always have the same clusters (positions and counts).

But when you start doing small adjustments for kingpin clustering algorithm it means change of base point from which cluster grid is calculated (it is specific drawback of grid clustering algorithm).

Real kingpin partially solves this visual inconsistency of changes in clusters positions by using normalization - every time you do panning (left-right-top-down without zooming) kingpin always uses base point from invisible grid of cluster size (one which is set using algorithm.annotationSize = CGSizeMake(50, 50)) that's why it doesn't look like recalculation from scratch every time.

In this application with "Load Data" you recreate annotation from scratch every time that's why you see those fluctuations as it is base point for algorithm computation that changes. In real application you will only have to call self.clusteringController.setAnnotations(places) once and then call clusteringController.refresh(true) like is demonstrated by kingpin-examples app.

I believe this sounds obscure, let me know if it somehow clarifies your confusion :)

@smahmoodpbm
Copy link
Author

I may have caused the confusion by putting together the image and not adding enough detail.

In total for the test project there are 115 annotations, which appear correctly if you load data from North America (not over the dateline). However if you load data from the dateline the counts for the clusters are about 390 annotations.

The counts for the number of annotations look to double or triple up when you are over the international date line and are correct when you are not over the date line.

Im looking into this more but annotationsInMapRect may be returning the same annotations for both the left and right annotation.

[annotationsLeft arrayByAddingObjectsFromArray:annotationsRight]

@stanislaw
Copy link
Collaborator

@smahmoodpbm thanks for reviewing this thoroughly. Indeed it was my quick fix based on what Kent Beck calls Obvious Implementation but without any tests :)

Now I have made it to handle remaining edge cases correctly.

Try the latest branch: 20160210-kingpin-international-dateline.

@stanislaw
Copy link
Collaborator

If everything is fine, I'll add this proper implementation with tests to kingpin here.

@smahmoodpbm
Copy link
Author

@stanislaw Thanks!! Everything looks good to add to the proper implementation.

@stanislaw
Copy link
Collaborator

@smahmoodpbm, I have just released 0.3.2 having this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants