forked from jellehelsen/mapkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMKGeocoder.j
62 lines (43 loc) · 1.14 KB
/
MKGeocoder.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@import <Foundation/CPObject.j>
@import "MKPlacemark.j"
@implementation MKGeocoder : CPObject
{
CLLocationCoordinate2D coordinate @accessors(readonly);
CPPlacemark placemark @accessors(readonly);
id delegate @accessors;
}
- (id)initWithAdress:(CPString)anAddress
{
if (self = [super init])
{
self.address = anAddress;
}
return self;
}
-(void)cancel
{
}
-(void)start
{
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ address: address}, function(inResult, inGeocoderStatus) {
if (inGeocoderStatus != google.maps.GeocoderStatus.OK || inResult.length == 0)
{
if([delegate respondsToSelector:@selector(geocoder:didFailWithError:)])
{
//TODO : Better Error Message
[delegate geocoder:self didFailWithError:@"Geocoding error"];
}
}
else
{
self.placemark = [[MKPlacemark alloc] initWithJSON:inResult[0]];
self.coordinate = self.placemark.coordinate;
if([delegate respondsToSelector:@selector(geocoder:didFindLocation:)])
{
[delegate geocoder:self didFindLocation:self.coordinate];
}
}
});
}
@end