Skip to content

Commit da32914

Browse files
committed
initial commit
1 parent 2a4ef92 commit da32914

10 files changed

+639
-0
lines changed

CustomAnnotation/Annotation.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Annotation.h
3+
// GeoPOC
4+
//
5+
// Created by raw engineering, inc on 8/14/12.
6+
// Copyright (c) 2012 raw engineering, inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <MapKit/MapKit.h>
11+
12+
@interface Annotation : NSObject <MKAnnotation>
13+
14+
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
15+
@property (nonatomic, copy) NSString *title;
16+
@property (nonatomic, copy) NSString *subtitle;
17+
@property (nonatomic, strong) MKPlacemark* placemark;
18+
@property (nonatomic, strong) NSString *userType;
19+
@property (nonatomic, strong) NSString *date;
20+
21+
- (id)initWithLocation:(CLLocationCoordinate2D)coord;
22+
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate;
23+
@end

CustomAnnotation/Annotation.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Annotation.m
3+
// GeoPOC
4+
//
5+
// Created by raw engineering, inc on 8/14/12.
6+
// Copyright (c) 2012 raw engineering, inc. All rights reserved.
7+
//
8+
9+
#import "Annotation.h"
10+
11+
@implementation Annotation
12+
13+
@synthesize coordinate;
14+
@synthesize title;
15+
@synthesize subtitle;
16+
@synthesize placemark;
17+
@synthesize userType;
18+
@synthesize date;
19+
20+
- (id)initWithLocation:(CLLocationCoordinate2D)coord {
21+
self = [super init];
22+
if (self) {
23+
coordinate = coord;
24+
}
25+
return self;
26+
}
27+
28+
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate {
29+
coordinate = newCoordinate;
30+
}
31+
32+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CustomAnnotationView.h
3+
// GeoPOC
4+
//
5+
// Created by raw engineering, inc on 8/17/12.
6+
// Copyright (c) 2012 raw engineering, inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <MapKit/MapKit.h>
11+
12+
@protocol CustomAnnotationDelegate;
13+
14+
@interface CustomAnnotationView : MKPinAnnotationView
15+
16+
@property (strong, nonatomic) UIView *calloutView;
17+
@property (assign, nonatomic) CGRect endFrame;
18+
@property (strong, nonatomic) id <CustomAnnotationDelegate> delegate;
19+
@property (strong, nonatomic) UIButton *shareButton;
20+
@property (strong, nonatomic) UILabel *dateLabel;
21+
@property (strong, nonatomic) UIButton *clearButton;
22+
23+
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;
24+
- (void)animateCalloutAppearance;
25+
- (void)buttonClicked:(id)sender;
26+
27+
@end
28+
29+
@protocol CustomAnnotationDelegate <NSObject>
30+
31+
@optional
32+
- (void)didSelectButtonAtIndex:(NSInteger)index forAnnotation:(id<MKAnnotation>)annotation;
33+
34+
@end
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//
2+
// CustomAnnotationView.m
3+
// GeoPOC
4+
//
5+
// Created by raw engineering, inc on 8/17/12.
6+
// Copyright (c) 2012 raw engineering, inc. All rights reserved.
7+
//
8+
9+
#import "CustomAnnotationView.h"
10+
#import "Annotation.h"
11+
#import "AppConstants.h"
12+
13+
@implementation CustomAnnotationView
14+
15+
@synthesize calloutView;
16+
@synthesize endFrame;
17+
@synthesize delegate;
18+
@synthesize shareButton;
19+
@synthesize dateLabel;
20+
@synthesize clearButton;
21+
22+
- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
23+
[super setSelected:selected animated:animated];
24+
Annotation *ann = self.annotation;
25+
if(selected)
26+
{
27+
//Add your custom view to self...
28+
calloutView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"graphic_mapCallout.png"]];
29+
[calloutView setFrame:CGRectMake(-46, 35, 0, 0)];
30+
[calloutView setUserInteractionEnabled:YES];
31+
[calloutView sizeToFit];
32+
33+
CGFloat bottom;
34+
35+
if ([ann.userType isEqualToString:SENDER]) {
36+
shareButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
37+
[shareButton setTitle:SHARE forState:UIControlStateNormal];
38+
[shareButton setFrame:CGRectMake(12, 25, 88, 25)];
39+
[shareButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
40+
[shareButton setTag:0];
41+
[calloutView addSubview:shareButton];
42+
bottom = shareButton.frame.origin.y + shareButton.frame.size.height + 7;
43+
}else if([ann.userType isEqualToString:RECEIVER]) {
44+
dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(12, 25, 88, 30)];
45+
46+
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
47+
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ssZZZZ"];
48+
49+
NSDateFormatter *formatter2 = [[NSDateFormatter alloc]init];
50+
[formatter2 setDateFormat:@"MM/dd/yyyy h:mm a"];
51+
52+
[dateLabel setText:[NSString stringWithFormat:@"Sent %@",[formatter2 stringFromDate:[formatter dateFromString:[ann.date stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]]];
53+
54+
formatter = nil;
55+
formatter2 = nil;
56+
57+
[dateLabel setFont:[UIFont boldSystemFontOfSize:11.5]];
58+
[dateLabel setBackgroundColor:[UIColor clearColor]];
59+
[dateLabel setTextColor:[UIColor whiteColor]];
60+
[dateLabel setTextAlignment:UITextAlignmentCenter];
61+
[calloutView addSubview:dateLabel];
62+
[dateLabel setNumberOfLines:2];
63+
64+
bottom = dateLabel.frame.origin.y + dateLabel.frame.size.height + 7;
65+
}
66+
67+
clearButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
68+
[clearButton setTitle:CLEAR forState:UIControlStateNormal];
69+
[clearButton setFrame:CGRectMake(12, bottom, 88, 25)];
70+
[clearButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
71+
[clearButton setTag:1];
72+
[calloutView addSubview:clearButton];
73+
74+
[self animateCalloutAppearance];
75+
[self addSubview:calloutView];
76+
}
77+
else
78+
{
79+
//Remove your custom view...
80+
[calloutView removeFromSuperview];
81+
}
82+
}
83+
84+
- (void)buttonClicked:(id)sender{
85+
UIButton *button = (UIButton *)sender;
86+
[delegate didSelectButtonAtIndex:button.tag forAnnotation:self.annotation];
87+
}
88+
89+
- (void)didAddSubview:(UIView *)subview{
90+
if ([[[subview class] description] isEqualToString:@"UICalloutView"]) {
91+
for (UIView *subsubView in subview.subviews) {
92+
if ([subsubView class] == [UIImageView class]) {
93+
UIImageView *imageView = ((UIImageView *)subsubView);
94+
[imageView removeFromSuperview];
95+
}else if ([subsubView class] == [UILabel class]) {
96+
UILabel *labelView = ((UILabel *)subsubView);
97+
[labelView removeFromSuperview];
98+
}
99+
}
100+
}
101+
}
102+
103+
- (void)animateCalloutAppearance {
104+
CGFloat scale = 0.001f;
105+
calloutView.transform = CGAffineTransformMake(scale, 0.0f, 0.0f, scale, 0, -50);
106+
107+
[UIView animateWithDuration:0.12f delay:0 options:UIViewAnimationCurveEaseOut animations:^{
108+
CGFloat scale = 1.05f;
109+
calloutView.transform = CGAffineTransformMake(scale, 0.0f, 0.0f, scale, 0, 2);
110+
} completion:^(BOOL finished) {
111+
[UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{
112+
CGFloat scale = 0.95;
113+
calloutView.transform = CGAffineTransformMake(scale, 0.0f, 0.0f, scale, 0, -2);
114+
} completion:^(BOOL finished) {
115+
[UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{
116+
CGFloat scale = 1.0;
117+
calloutView.transform = CGAffineTransformMake(scale, 0.0f, 0.0f, scale, 0, 0);
118+
} completion:nil];
119+
}];
120+
}];
121+
}
122+
123+
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
124+
// if (CGRectContainsPoint(calloutView.frame, point)) {
125+
// NSLog(@"YES");
126+
// }
127+
// NSLog(@"Point %f",point.x);
128+
return YES;
129+
}
130+
131+
132+
@end

CustomAnnotation/MapViewController.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// MapViewController.h
3+
// GeoPOC
4+
//
5+
// Created by raw engineering, inc on 8/11/12.
6+
// Copyright (c) 2012 raw engineering, inc. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
#import <MapKit/MapKit.h>
11+
#import "MessageUI/MessageUI.h"
12+
#import "CustomAnnotationView.h"
13+
14+
@class Annotation;
15+
@interface MapViewController : UIViewController<MKMapViewDelegate, MFMessageComposeViewControllerDelegate, CustomAnnotationDelegate, CLLocationManagerDelegate>
16+
17+
@property (strong, nonatomic) MKMapView *geomapView;
18+
@property (strong, nonatomic) CLGeocoder *geocoder;
19+
@property (strong, nonatomic) UIBarButtonItem *compassBarButton;
20+
@property (strong, nonatomic) UIBarButtonItem *dropPinBarButton;
21+
@property (strong, nonatomic) UIBarButtonItem *shareMyLocationBarButton;
22+
@property (assign, nonatomic) BOOL showHeading;
23+
@property (strong, nonatomic) UIImageView* adImageView;
24+
25+
- (void)dropPinAt:(NSArray *)latLongArray;
26+
- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer;
27+
- (void)showCurrentLocation;
28+
- (void)dropPin;
29+
- (void)removeAllAnnotations;
30+
- (void)shareLocation:(id<MKAnnotation>)annotation;
31+
- (void)addBannerAd;
32+
@end

0 commit comments

Comments
 (0)