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

NaN at some values #107

Closed
ppamorim opened this issue Sep 25, 2015 · 18 comments
Closed

NaN at some values #107

ppamorim opened this issue Sep 25, 2015 · 18 comments

Comments

@ppamorim
Copy link

Hi.
Im studying this library, yesterday this library works fine. But today stops working I dont know what happens. Then, returns this:

captura de tela 2015-09-25 as 16 48 38

My annotation is equals of the TestAnnotation, the complete source of the MapViewController is there: https://gist.github.com/ppamorim/5c6e8d1800a4c7b5a99f

EDIT:

This happens with I use the method setAnnotations. This happens with PureLayout, I used the wrong way to create the view (with bounds) and works fine.

captura de tela 2015-09-25 as 18 35 18

@stanislaw
Copy link
Collaborator

@ppamorim, thanks for reporting this.

It is good that you mentioned PureLayout as it can be related to some unusual frame sizes.

Could you set a break point or just NSLog to the beginning of that function MKMapRectNormalizeToCellSize so that I could see what is your input of both MKMapRect mapRect and MKMapSize cellSize variables? This will allow me to resolve this issue as soon as possible.

@ppamorim
Copy link
Author

captura de tela 2015-09-26 as 20 31 28
captura de tela 2015-09-26 as 20 31 58
captura de tela 2015-09-26 as 20 32 14

If you want I can share the source code with you.

@stanislaw
Copy link
Collaborator

That makes a lot of sense. You're trying to run clustering on map of MKMapRect: {.x = -1, y = -1, width = 0, height = 0} so that this issue pretty much reminds me another one: iOS 7.1 64-bit crash KPTreeController #40.

There I just decided to drop out from clustering procedure if one tries to cluster map of size MKMapSizeZero as it does not make any sense. Actually that is strange that you're able to enter clustering algorithm as you should probably also have map of size MKMapSizeZero.

To verify this put breakpoint on this line -- we want to know what exactly your map view's size is at the moment when clustering starts.

@ppamorim
Copy link
Author

captura de tela 2015-09-27 as 12 44 19

@stanislaw
Copy link
Collaborator

Please do the same but this time expand _mapView I need to look at it's dimensions.

@stanislaw
Copy link
Collaborator

Or if expansion will not reveal visibleMapRect please do it manually like po self.mapView.visibleMapRect.

@ppamorim
Copy link
Author

@stanislaw The log is too big, I`m lost :s

@stanislaw
Copy link
Collaborator

I mean we just want to know what your map view's visibleMapRect is when you are at https://github.com/itsbonczek/kingpin/blob/18cb81634e7471943f3b6eaf55f09372f8d5c6ea/kingpin/KPClusteringController.m#L116.

@ppamorim
Copy link
Author

I searched about width and height of the element.
captura de tela 2015-09-28 as 09 48 18
captura de tela 2015-09-28 as 09 48 28

@stanislaw
Copy link
Collaborator

Yes and no :)

The break point is correct but I want you to do po self.mapView.visibleMapRect on it. Please do :)

@ppamorim
Copy link
Author

@stanislaw I`ll do it on my public repository taht is named Fun-With-Swift, then, you can test, of course.

@stanislaw
Copy link
Collaborator

Yes that will work. Is that repository already has what I can test or you're going to push something on top of it?

@ppamorim
Copy link
Author

not ready yet. I`ll push something soon.

@ppamorim
Copy link
Author

@stanislaw Done!
https://github.com/ppamorim/Fun-with-Swift
Clone it and have fun!

@stanislaw
Copy link
Collaborator

@ppamorim thank you for crafting that test application as it helped me to resolve this issue very quickly.

Your issue is sort of edge case: since you're using PureLayout you should be careful with the exact moment when you're trying to start clustering controller:

currently in your application you call clusteringController.setAnnotations(annotations()) which triggers clustering on your mapView which has zero map rect at that moment.

I have pushed 0.3.1 to CocoaPods -- in this new version kingpin just drops out of clustering if a map is zero, so you should add another call to clusteringController: clusteringController.refresh(true) where you would be sure that your map is set to real non-zero dimensions you expect it to have (somewhere later in View Controller lifecycle like: viewWillAppear or viewDidLayoutSubviews.

P.S. For me as a developer your report gives valuable feedback about weakness of this part of kingpin's public API -- eventually next versions of kingpin will not have setAnnotations: method triggering clustering algorithm under the hood i.e. procedure of setting annotations (and building annotation tree for it) and clustering procedure will be called separately to prevent issues like that.

Let me know if this works for you.

@ppamorim
Copy link
Author

ppamorim commented Oct 2, 2015

I think that the initilizer needs to be invocated with the UIView lifecycle. What do you think about it?

@ppamorim
Copy link
Author

ppamorim commented Oct 2, 2015

@stanislaw Solved!
But I noticed another bizarre bug:
captura de tela 2015-10-01 as 22 57 54

Happens when I click in the cluster or pin. Look like the frame of the map is moving. Please ignore the black view.

@stanislaw
Copy link
Collaborator

I am afraid this is not related to kingpin but rather to some magic that is behind PureLayout or just auto-layout in general.

The only thing kinpin does here is that it sets map region i.e. it does not contain any code that would affect mapView's frame size/origin.

Try investigating the auto-layout details of your implementation.

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

No branches or pull requests

2 participants