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

Missing styling of Annotation / View #103

Closed
4 tasks done
sebleclerc opened this issue Jan 25, 2019 · 8 comments
Closed
4 tasks done

Missing styling of Annotation / View #103

sebleclerc opened this issue Jan 25, 2019 · 8 comments

Comments

@sebleclerc
Copy link

sebleclerc commented Jan 25, 2019

I upgraded from Cluster 2.2.8 to latest 2.4.1. After the upgrade, I had some errors stating that ClusterAnnotationStyle does not exists anymore.

New Issue Checklist

Issue Description

How am I suppose to style my pins on the map now? I read a little bit and saw the style property have been made private but that's pretty much it.

In the doc I see this:

let annotation = Annotation()
annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
annotation.style = .color(color, radius: 25) // .image(UIImage(named: "pin"))
clusterManager.add(annotation)

But the style property doesn't exists anymore.

I am clearly missing something here but can't find it...

Thanks!

Environment

  • iOS Version: 12.1
  • Device(s): Simulator / iPhone 6 / iPhone XR
@iMentock
Copy link

iMentock commented Jan 27, 2019

I am having this same issue.

edit I am reverting back to 2.2.8 till update on this issue.

@efremidze efremidze mentioned this issue Jan 28, 2019
3 tasks
@efremidze
Copy link
Owner

efremidze commented Jan 28, 2019

Sorry for the confusion. I've deprecated the ClusterAnnotationStyle and instead added new ClusterAnnotationView subclasses. You can now achieve the same UI using:

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    let annotationView = CountClusterAnnotationView(annotation: annotation, reuseIdentifier: reuseIdentifier)
    annotationView.countLabel.backgroundColor = color
    return annotationView
}

https://github.com/efremidze/Cluster/blob/master/Example/AnnotationView.swift

Feel free to provide feedback on the implementation.

@efremidze
Copy link
Owner

efremidze commented Jan 29, 2019

@sebleclerc @guapokat I've reintroduced the ClusterAnnotationStyle but you need to use the StyledClusterAnnotationView to support it. It's out in v2.4.3.

@sebleclerc
Copy link
Author

@efremidze Thanks for the quick changes!

My original question was also about "regular" pin. What I did was to subclass Annotation and use that style property. After getting into the code again, I see what my problem was. I'll have to change that a bit to make sure I'm 100% good with the upcoming 2.5.0 release that will remove the style property.

@efremidze
Copy link
Owner

efremidze commented Jan 30, 2019

I can continue supporting the style property but it's error prone since the library doesn't consider the style property when grouping clusters. It currently just checks the first element in the cluster and uses it's style. I need to come up with a better solution to support multiple styles.

@sebleclerc
Copy link
Author

My mind is more clear on what it involves removing the style property. I don't really care if it's removed, you probably know better than me if it could cause problem 😃

I used the style for the regular pins to store their color because different colors have different meaning in my app. I have removed the use of style for these.

As you mentioned, cluster view use the first element style, which is not something I want. I want to have all cluster views with the same color. If that would be possible when removing the style property, I'm totally fine.

@efremidze
Copy link
Owner

efremidze commented Jan 30, 2019

In your case it wouldn't cause a problem.

@sebleclerc
Copy link
Author

sebleclerc commented Jan 31, 2019

Good to hear! Thanks a lot for the quick answer and changes.

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

3 participants