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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s