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

Added Web Images Support =) #18

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1,291 changes: 951 additions & 340 deletions Demo/JPSThumbnailAnnotation.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Demo/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Uncomment this line to define a global platform for your project
platform :ios, "6.0"

#inhibiting all warnings coming from CocoaPods libraries
inhibit_all_warnings!

target "JPSThumbnailAnnotation" do

pod 'UIActivityIndicator-for-SDWebImage', '~> 1.2'


end

48 changes: 48 additions & 0 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
PODS:
- libwebp (0.4.1):
- libwebp/dec
- libwebp/demux
- libwebp/dsp
- libwebp/enc
- libwebp/mux
- libwebp/utils
- libwebp/webp
- libwebp/dec (0.4.1):
- libwebp/enc
- libwebp/utils
- libwebp/demux (0.4.1):
- libwebp/utils
- libwebp/dsp (0.4.1):
- libwebp/dec
- libwebp/enc
- libwebp/utils
- libwebp/enc (0.4.1):
- libwebp/utils
- libwebp/mux (0.4.1):
- libwebp/utils
- libwebp/utils (0.4.1):
- libwebp/dsp
- libwebp/webp
- libwebp/webp (0.4.1)
- SDWebImage (3.7.1):
- SDWebImage/Core
- SDWebImage/MapKit
- SDWebImage/WebP
- SDWebImage/Core (3.7.1)
- SDWebImage/MapKit (3.7.1):
- SDWebImage/Core
- SDWebImage/WebP (3.7.1):
- libwebp
- SDWebImage/Core
- UIActivityIndicator-for-SDWebImage (1.2):
- SDWebImage (~> 3.7)

DEPENDENCIES:
- UIActivityIndicator-for-SDWebImage (~> 1.2)

SPEC CHECKSUMS:
libwebp: 88e6e172a01df354b0a78400d2e5b87a9f2796cb
SDWebImage: 116e88633b5b416ea0ca4b334a4ac59cf72dd38d
UIActivityIndicator-for-SDWebImage: 8bd92c15280fbe54816448c6b14674145eee05c7

COCOAPODS: 0.32.1
11 changes: 10 additions & 1 deletion Demo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ - (NSArray *)annotations {
ottawa.coordinate = CLLocationCoordinate2DMake(45.43f, -75.70f);
ottawa.disclosureBlock = ^{ NSLog(@"selected Ottawa"); };

// Central Park -- (Web image Example by using imageURL parameter)
JPSThumbnail *cPark = [[JPSThumbnail alloc] init];
cPark.imageURL = [NSURL URLWithString:@"http://insidenanabreadshead.files.wordpress.com/2011/01/ynp-yellowstone-entry-sign.jpg"];
cPark.title = @"Yellowstone National Park";
cPark.subtitle = @"Wonders of Nature";
cPark.coordinate = CLLocationCoordinate2DMake(44.427844f, -110.588519f);
cPark.disclosureBlock = ^{ NSLog(@"selected Yellowstone Park"); };

return @[[JPSThumbnailAnnotation annotationWithThumbnail:empire],
[JPSThumbnailAnnotation annotationWithThumbnail:apple],
[JPSThumbnailAnnotation annotationWithThumbnail:ottawa]];
[JPSThumbnailAnnotation annotationWithThumbnail:ottawa],
[JPSThumbnailAnnotation annotationWithThumbnail:cPark]];
}

#pragma mark - MKMapViewDelegate
Expand Down
6 changes: 5 additions & 1 deletion JPSThumbnailAnnotation.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'JPSThumbnailAnnotation'
s.version = '1.0.0'
s.version = '1.0.1'
s.platform = :ios
s.license = 'MIT'
s.summary = 'A simple mapkit annotation for displaying images and details.'
Expand All @@ -12,5 +12,9 @@ Pod::Spec.new do |s|

s.source_files = 'JPSThumbnailAnnotation/*.{h,m}'
s.frameworks = 'QuartzCore', 'MapKit', 'CoreLocation'

#specifying dependencies for Web image Downloads
s.dependency 'UIActivityIndicator-for-SDWebImage', '~> 1.2'

s.requires_arc = true
end
1 change: 1 addition & 0 deletions JPSThumbnailAnnotation/JPSThumbnail.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef void (^ActionBlock)();
@interface JPSThumbnail : NSObject

@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) NSURL *imageURL;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
Expand Down
16 changes: 15 additions & 1 deletion JPSThumbnailAnnotation/JPSThumbnailAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import QuartzCore;
#import "JPSThumbnailAnnotationView.h"
#import "JPSThumbnail.h"
#import "UIImageView+UIActivityIndicatorForSDWebImage.h"

NSString * const kJPSThumbnailAnnotationViewReuseID = @"JPSThumbnailAnnotationView";

Expand Down Expand Up @@ -126,10 +127,23 @@ - (void)updateWithThumbnail:(JPSThumbnail *)thumbnail {
self.coordinate = thumbnail.coordinate;
self.titleLabel.text = thumbnail.title;
self.subtitleLabel.text = thumbnail.subtitle;
self.imageView.image = thumbnail.image;
[self assignImageWithThumbnail:thumbnail];
self.disclosureBlock = thumbnail.disclosureBlock;
}

-(void)assignImageWithThumbnail:(JPSThumbnail *)thumbnail {

//figure out if we Should directly set image or use URL to download it instead
if (thumbnail.image) {
self.imageView.image = thumbnail.image;

}else if(thumbnail.imageURL){

[self.imageView setImageWithURL:thumbnail.imageURL placeholderImage:nil usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
}

}

#pragma mark - JPSThumbnailAnnotationViewProtocol

- (void)didSelectAnnotationViewInMap:(MKMapView *)mapView {
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JPSThumbnailAnnotation

JPSThumbnailAnnotation is a simple mapkit annotation view for displaying images with clean design and animations. It is 100% programmatically drawn and styled for iOS 7.
JPSThumbnailAnnotation is a simple mapkit annotation view for displaying images with clean design and animations. It is 100% programmatically drawn and styled for iOS 7. It supports both local and Web images.

![JPSThumbnailAnnotation in action](screenshots2.jpg)

Expand Down Expand Up @@ -31,6 +31,18 @@ thumbnail.disclosureBlock = ^{ NSLog(@"selected Empire"); };
[mapView addAnnotation:[JPSThumbnailAnnotation annotationWithThumbnail:thumbnail]];
```

Additionally, you can display Web images, by simply leaving the image property set to nil when creating the JPSThumbnail instances, and providing an imageURL instead.

``` objc
// Central Park -- (Web image Example by using imageURL parameter)
JPSThumbnail *cPark = [[JPSThumbnail alloc] init];
cPark.imageURL = [NSURL URLWithString:@"http://insidenanabreadshead.files.wordpress.com/2011/01/ynp-yellowstone-entry-sign.jpg"];
cPark.title = @"Yellowstone National Park";
cPark.subtitle = @"Wonders of Nature";
cPark.coordinate = CLLocationCoordinate2DMake(44.427844f, -110.588519f);
cPark.disclosureBlock = ^{ NSLog(@"selected Yellowstone Park"); };
```

### Usage notes

Make sure the mapView implements the following 3 MKMapViewDelegate methods:
Expand All @@ -56,6 +68,10 @@ Make sure the mapView implements the following 3 MKMapViewDelegate methods:
}
```

### Dependencies
This class uses SDWebImage by means of the popular category "UIImageView+UIActivityIndicatorForSDWebImage.h" to allow Web image downloads


## License

MIT Licensed.