-
Notifications
You must be signed in to change notification settings - Fork 2
Elevation
aferre edited this page Oct 8, 2011
·
2 revisions
cf Google Geocoding API page for the behaviour of the WS.
Retrieve elevation for location(s):
afGMapsElevationRequest *req = [afGMapsElevationRequest request];
req.afDelegate = self;
[req addLocation:[ [ CLLocation alloc ] initWithLatitude:11.22 longitude:11.33 ] ];
[req addLocation:[ [ CLLocation alloc ] initWithLatitude:11.21 longitude:11.34 ] ];
[req setUseSensor:YES];
[req startAsynchronous];
Or to reverse geocode coordinates:
afGMapsElevationRequest *req = [afGMapsElevationRequest request];
req.afDelegate = self;
[req addPathPoint:[ [CLLocation alloc] initWithLatitude:11.22 longitude:11.33]];
[req addPathPoint:[ [CLLocation alloc] initWithLatitude:11.90 longitude:11.10]];
req.pathNumber = 100 ; //will return 100 samples
[req setUseSensor:YES];
[req startAsynchronous];
Then, simply make your class inherit the afGoogleMapsElevationDelegate protocol, and implement the following delegate functions (all optional):
-(void) afElevationWSStarted:(afGMapsElevationRequest *)ws ;
-(void) afElevationWSFailed:(afGMapsElevationRequest *)ws withError:(NSError *)er;
-(void) afElevationWS:(afGMapsElevationRequest *)ws gotElevation:(NSNumber *)elevation forLocation:(CLLocation *)location;
The array returned by the following delegate contains dictionnaries holding the results available. They have the same structure as the ones returned by Google Web Services:
{
"location": {
"lat": 39.7391536,
"lng": -104.9847034
},
"elevation": 1608.8402100
}
-(void) afElevationWS:(afGMapsElevationRequest *)ws gotResults:(NSArray *) results;