forked from cappuccino/MapKit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMKGeocoder.j
37 lines (28 loc) · 806 Bytes
/
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
@import <Foundation/CPObject.j>
@implementation MKGeocoder : CPObject
{
id delegate @accessors;
}
- (id)init
{
if (self = [super init])
{
}
return self;
}
- (void)geocodeAddress:(CPString)anAddress doneSelector:(SEL)aSelector
{
var geocoder = new google.maps.Geocoder();
var value = null;
geocoder.geocode({ address: anAddress}, function(inResult, inGeocoderStatus) {
if (inGeocoderStatus != google.maps.GeocoderStatus.OK)
return;
if (inResult.length == 0)
return;
var resultLatLng = inResult && inResult[0] && inResult[0].geometry && inResult[0].geometry.location;
if (!resultLatLng) return;
value = CLLocationCoordinate2DFromLatLng(resultLatLng);
objj_msgSend([self delegate], aSelector, value);
});
}
@end