Month: May 2013

Thumbnail Based MapView Annotation

Posted on

JPSThumbnailAnnotation is an open source library to customize your MapKit annotation view for displaying image thumbnail  along with title and subtitle.  Here is a quick screenshot from my sample project using this library.

map

Setup

Its free, and open source; You need to download JPSThumbnailAnnotation library from github and drag/drop the directory into your project; You will have following six files in library;

  1. JPSThumbnail.h
  2. JPSThumbnailAnnotation.h
  3. JPSThumbnailAnnotation.m
  4. JPSThumbnailAnnotationView.h
  5. JPSThumbnailAnnotationView.m
  6. JPSThumnail.m

Usage

 import JPSThumbnailAnnotation.h and add the following line of code to add one annotation on your map view

JPSThumbnail *faisaMosqueAnnotation = [[JPSThumbnail alloc] init];
faisaMosqueAnnotation.image = [UIImage imageNamed:@"faisalMasjid.jpg"];
faisaMosqueAnnotation.title = kFaisalMasjidTitle;
faisaMosqueAnnotation.subtitle = kFaisalMasjidSubTitle;
faisaMosqueAnnotation.coordinate = CLLocationCoordinate2DMake(33.72976, 73.03698);
faisaMosqueAnnotation.disclosureBlock = ^{ NSLog(@"Faisal Mosque selected"); };
JPSThumbnailAnnotation *annotation = [[JPSThumbnailAnnotation alloc] initWithThumbnail:faisaMosqueAnnotation];
[mapView addAnnotation:annotation];

You are good to go now .. You can download a sample project from here.

Flag Counter

Happy Programming .. (:

Advertisements