I am developing app with mapview functionality. I want to show custom pin image on mapview, click on that open custom callout bubble with image and title. With click on that callout bubble view I would like to do some functionality. How to achieve this? Any help will be appreciated
Asked
Active
Viewed 9,348 times
4
-
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=callout+ – Rushabh Mar 01 '14 at 05:20
3 Answers
7
Head over to CocoaControls for custom controls. I bet you'll find something useful for your requirement.
Here are some search results from CocoaControls:
Custom Pin Image
There are already questions on SO which answer this here and here and many more. I daresay you'll find your answer among them. Basically, the code is
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
NSString *annotationIdentifier = @"CustomViewAnnotation";
MKAnnotationView* annotationView = [mapview dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if(!annotationView)
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier]];
}
annotationView.image = [UIImage imageNamed:@"map_location_pin.png"];
annotationView.canShowCallout= YES;
return annotationView;
}
-
I have set custom image as annotation, now i want to open custom callout bubble on click of that image. How to achieve this? – user2996143 Mar 01 '14 at 05:32
-
You can use the `MKMapViewDelegate`'s method `mapView:didSelectAnnotationView:` to handle the click and present a popup from that method. – aksh1t Mar 01 '14 at 05:36
-
Oh and yes, I suppose if you are showing your own custom callout, you will need to turn off the default callout by setting `canShowCallout` to `NO`. Play around with the code and see if you get what you want. – aksh1t Mar 01 '14 at 05:37
-
Glad to be of help. Please consider accepting the answer if it solved your problem. Thanks! – aksh1t Mar 01 '14 at 05:41
0
Please check out it: https://github.com/grgcombs/MultiRowCalloutAnnotationView
Hope, It will may help you,
:)

Gaurav
- 299
- 4
- 15