forked from vvanhee/Google-Local-Search-iOS
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// GoogleLocalObject.h | ||
// BabyMap | ||
// | ||
// Created by Victor C Van Hee on 10/13/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <MapKit/MapKit.h> | ||
|
||
@interface GoogleLocalObject : NSObject <MKAnnotation> { | ||
NSString *title; | ||
NSString *subtitle; | ||
CLLocationCoordinate2D coordinate; | ||
NSString *streetAddress; | ||
NSString *city; | ||
NSString *region; | ||
NSString *phoneNumber; | ||
NSString *country; | ||
NSString *searchTerms; | ||
NSArray *fullAddressArray; | ||
NSString *fullAddressString; | ||
} | ||
|
||
@property (nonatomic, assign) CLLocationCoordinate2D coordinate; | ||
@property (nonatomic, retain) NSString *title; | ||
@property (nonatomic, retain) NSString *subtitle; | ||
@property (nonatomic, retain) NSString *streetAddress; | ||
@property (nonatomic, retain) NSArray *fullAddressArray; | ||
@property (nonatomic, retain) NSString *fullAddressString; | ||
@property (nonatomic, retain) NSString *city; | ||
@property (nonatomic, retain) NSString *region; | ||
@property (nonatomic, retain) NSString *phoneNumber; | ||
@property (nonatomic, retain) NSString *country; | ||
@property (nonatomic, retain) NSString *searchTerms; | ||
|
||
- (id)initWithJsonResultDict:(NSDictionary *)jsonResultDict; | ||
|
||
- (id)initWithTitle:(NSString *)tit subtitle:(NSString *)sub latitude:(double)lat longitude:(double)lng streetAddress:(NSString *)strAdd city:(NSString *)cit region:(NSString *)reg phoneNumber:(NSString *)phone country:(NSString *)coun searchTerms:(NSString *)terms fullAddress:(NSArray *)fullAddrss; | ||
|
||
- (id)initWithTitle:(NSString *)tit latitude:(double)lat longitude:(double)lng streetAddress:(NSString *)strAdd city:(NSString *)cit region:(NSString *)reg phoneNumber:(NSString *)phone country:(NSString *)coun searchTerms:(NSString *)terms fullAddress:(NSArray *)fullAddrss; | ||
|
||
- (id)initWithJsonResultDict:(NSDictionary *)jsonResultDict searchTerms:(NSString *)terms; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// GoogleLocalObject.m | ||
// | ||
// Created by Victor C Van Hee on 10/13/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "GoogleLocalObject.h" | ||
|
||
@implementation GoogleLocalObject | ||
|
||
@synthesize title, subtitle, coordinate, streetAddress, phoneNumber, city, region, country, searchTerms, fullAddressArray, fullAddressString; | ||
|
||
- (NSString *)description | ||
{ | ||
NSString *desc = [NSString stringWithFormat:@"title: %@ subtitle: %@ phoneNumber: %@ lat:%f lng:%f streetAddress: %@ city: %@ region: %@ country: %@ searchTerms: %@",title,subtitle,phoneNumber,coordinate.latitude, coordinate.longitude, streetAddress, city, region, country, searchTerms]; | ||
NSLog(@"%@",desc); | ||
return desc; | ||
} | ||
|
||
- (id)initWithTitle:(NSString *)tit subtitle:(NSString *)sub latitude:(double)lat longitude:(double)lng streetAddress:(NSString *)strAdd city:(NSString *)cit region:(NSString *)reg phoneNumber:(NSString *)phone country:(NSString *)coun searchTerms:(NSString *)terms fullAddress:(NSArray *)fullAddrss | ||
{ | ||
self = [super init]; | ||
|
||
if (!self) | ||
return nil; | ||
[self setTitle:tit]; | ||
[self setSubtitle:sub]; | ||
[self setCoordinate:CLLocationCoordinate2DMake(lat, lng)]; | ||
[self setStreetAddress:strAdd]; | ||
[self setCity:cit]; | ||
[self setRegion:reg]; | ||
[self setPhoneNumber:phone]; | ||
[self setCountry:coun]; | ||
[self setSearchTerms:terms]; | ||
[self setFullAddressArray:fullAddrss]; | ||
NSMutableString *result = [[NSMutableString alloc] init]; | ||
for (NSObject *obj in fullAddrss) | ||
{ | ||
[result appendString:[obj description]]; | ||
if (obj != [fullAddrss lastObject]) { | ||
[result appendString:@", "]; | ||
} | ||
} | ||
[self setFullAddressString:result]; | ||
return self; | ||
} | ||
|
||
- (id)initWithJsonResultDict:(NSDictionary *)jsonResultDict { | ||
[self initWithJsonResultDict:jsonResultDict searchTerms:@""]; | ||
return self; | ||
} | ||
|
||
- (id)initWithJsonResultDict:(NSDictionary *)jsonResultDict searchTerms:(NSString *)terms | ||
{ | ||
|
||
[self initWithTitle:[jsonResultDict objectForKey:@"titleNoFormatting"] latitude:[[jsonResultDict objectForKey:@"lat"] doubleValue] longitude:[[jsonResultDict objectForKey:@"lng"] doubleValue] streetAddress:[jsonResultDict objectForKey:@"streetAddress"] city:[jsonResultDict objectForKey:@"city"] region:[jsonResultDict objectForKey:@"region"] phoneNumber:[[[jsonResultDict objectForKey:@"phoneNumbers"] objectAtIndex:0] objectForKey:@"number"] country:[jsonResultDict objectForKey:@"country"] searchTerms:terms fullAddress:[jsonResultDict objectForKey:@"addressLines"]]; | ||
return self; | ||
} | ||
|
||
//the below function sets the subtitle automatically to the street address | ||
- (id)initWithTitle:(NSString *)tit latitude:(double)lat longitude:(double)lng streetAddress:(NSString *)strAdd city:(NSString *)cit region:(NSString *)reg phoneNumber:(NSString *)phone country:(NSString *)coun searchTerms:(NSString *)terms fullAddress:(NSArray *)fullAddrss | ||
{ | ||
[self initWithTitle:tit subtitle:strAdd latitude:lat longitude:lng streetAddress:strAdd city:cit region:reg phoneNumber:phone country:coun searchTerms:terms fullAddress:fullAddrss]; | ||
return self; | ||
} | ||
|
||
|
||
- (void) dealloc | ||
{ | ||
NSLog(@"Google Local Object %@ deallocated",[self title]); | ||
[title release]; | ||
[subtitle release]; | ||
[streetAddress release]; | ||
[city release]; | ||
[region release]; | ||
[country release]; | ||
[phoneNumber release]; | ||
[searchTerms release]; | ||
[fullAddressArray release]; | ||
[fullAddressString release]; | ||
[super dealloc]; | ||
} | ||
|
||
@end |