itsbonczek / kingpin

A drop-in map annotation clustering library for MKMapView
Apache License 2.0
562 stars 91 forks source link

Remove MKMapView dependency #94

Open ivany4 opened 9 years ago

ivany4 commented 9 years ago

I would like to use this library with MKMapSnapshotter. Since, I have not MKMapView, I cannot use KPClusteringController.

stanislaw commented 9 years ago

Hello, @ivany4.

While our plans include complete removal of MKMapView dependency, they are not short term plans/activities and if taken out of a TODO-box right now would require too much of engineering effort for serious redesign of current kingpin architecture.

While it is unfortunate that we can't address your needs (sorry! try something other than kingpin) I would still like to hear from you about your use case and especially how do you use MKMapSnapshotter as I didn't have any experience with it so far.

Thanks for suggestion and please do share your use case so we could maybe reflect on priorities in our development plan.

ivany4 commented 9 years ago

Hi @stanislaw.

Thanks for the reply. I am currently trying to make use of FBAnnotationCluster library. It deals directly with annotations, which is more suitable for me.

Regarding MKMapSnapshotter, I am using is to generate a map image. It's a simple block based asynchronous API that returns you a UIImage upon completion. I use it because I do not need an interactive map, and I want to preload snapshots in the background in order to improve UI smoothness. I use a complex scrolling hierarchy, so mapViews introduce lags.

stanislaw commented 9 years ago

@ivany4, thanks for explanation!

Actually kingpin could be close enough to address your needs given the following changes would be made:

It is kingpin's algorithmic core: KPGridClusteringAlgorithm that actually performs clustering. The only place where it depends on MKMapView is it's ability to calculate expected annotation's view size: - [MKMapView convertCoordinate:toPointToView:] which allows the second stage of algorithm to merge clusters from adjacent cells which are located too close to each other (description of two stage algorithm can be found on README page). Once I had made an attempt to decouple KPGridClusteringAlgorithm from its dependency on MKMapView but it was reverted because it seemed like overengineering at that time.

Now I don't want to hack on kingpin quickly to bring this feature at all costs, but I'll definitely place this feature high enough in our priority list especially because it is closely related to Google Maps support #67 ticket which is also our plan.

Thanks for opening this issue as such issues give us a good vision of where and how-to actually refactor kingpin's code!

ivany4 commented 9 years ago

Yeah, I saw that it can be relatively easily abstracted from mapView, so this ticket was rather a suggestion than a complaint :) And thanks for mentioning another issue. Actually, I do need the very same algorithm for my another project that uses google maps. So I am sticking with another library at the moment as well... :) But I'll keep watching your progress.

itsbonczek commented 9 years ago

Thanks @ivany4. I agree with @stanislaw that we could be better about abstracting some of this code so that it's a more reusable. Good to start thinking about :)