1

This is my first question, and i am new to iOS. I am implementing pin clustering on map view , which in working fine for one type of pin but my requirement is to cluster different kind of pins with different cluster count on it when zoomed out i.e if one kind of pin shows river details on map view than these pins should cluster together and give a count on it and on other case if other pin is showing details for diversion on map view than these pins should cluster together separately from river pin and give a separate count on it. and this same case is followed for other 4 different kinds of pins.

And i have one more issue , how to implement different callout views for these above different kind of pins on same map view i.e suppose river pin have default callout which includes title,subtitle and accessory button. And on other side for Diversion pin i have my own custom call out view . So now i want is when i tap on river pin than default callout should pop out and when i tap on diversion pin than my own custom callout should pop out.And same for other kind of pins too.

Please help me out . I am working on these issues from last 2 weeks but nothing working out for me. Please help me out i want a solution for these problems badly.

NOTE: The custom callout and default callout should be implemented with pin clustering.

1 Answers1

0

I have created a demo, which will solve your problem about custom call out and default call out.

Answer

will guide you how to create custom call out and add pins for it.

This code contains PinAnnotation which is a subclass of MKAnnotation and acts to show custom call out.

For the default call out view you just have to add MKAnnotation to map and it will show default one.

How ever you can customise it if you want and create another sub class for it.

To test default call out with custom call out view. Download demo project from that answer link or directly from here.

Add below code at the end of viewDidLoad() and run the application.

MKPointAnnotation *pin = [[MKPointAnnotation alloc] init];
pin.coordinate = CLLocationCoordinate2DMake(34.65515f, 133.81951f);
pin.title = @"Default Pin";

[self.mapView addAnnotation:pin];

It will be looks like below:

enter image description here

Community
  • 1
  • 1
Kampai
  • 22,848
  • 21
  • 95
  • 95
  • I appreciate your answer @Kampai but i have already implemented default and custom callouts without pin clustering on my map view .But i want 2 different cluster in same map with different callout views. – Prabhjot Singh Dec 24 '14 at 12:14
  • As from my knowledge you can show one type of cluster at a time. However if some one does have provide mix images for same cluster than it looks like different cluster and call out on the basis of some constraints. – Kampai Dec 24 '14 at 12:17
  • Actually i have implemented this way also but the problem is that while implementing clustering i am not able to implement default and custom callout for different pins. If you have solution for this problem or any suggestion i want it very badly . Thanx – Prabhjot Singh Dec 24 '14 at 12:28
  • Have you check my demo, actually call out works on `MKAnnotationView` and you need to create sub class of that. And what you just have to do is add condition in `viewForAnnotation:` to decide for call out view. Have you tried this? – Kampai Dec 24 '14 at 12:36
  • I am implementing a CCHMapClusterController for clustering and implemented two different clusters on map with different pins successfully but the real issue is while implementing callouts for different pins in both of these clusters. If you want to know about CCHMapClusterController you can google it. – Prabhjot Singh Dec 24 '14 at 12:52
  • and i have added condition in viewForAnnotation: but its not working .I think the pins are of same class i.e CCHMapClusterController thats why the condition is not working. I really want some help – Prabhjot Singh Dec 24 '14 at 12:55
  • Use condition for example: `if (clusterAnnotation.isUniqueLocation) { annotationView = clusterAnnotationView; } else { // Create similar annotatioView }` – Kampai Dec 24 '14 at 13:22
  • Thank you @Kampai .I will implement this way and let you know . Hope this time my problem will solve. – Prabhjot Singh Dec 24 '14 at 13:48
  • 1
    Thank you very much @Kampai .. My problem is solved with the help of your demo callout code . Thank you again – Prabhjot Singh Dec 25 '14 at 10:30