I have been trying to add a link to Google Maps so that I can show some directions to a location. The only problem i’m having is the code not recognizing the method. Here’s samples below, hope they help.
.h:
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface More : UIViewController{
}
- (IBAction)directions:(id)sender;
-(CLLocationCoordinate2D)getCurrentLocation;
@end
.m:
- (IBAction)directions:(id)sender {
CLLocationCoordinate2D currentLocation = [self getCurrentLocation];
NSString* address = @"********";
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",
currentLocation.latitude, currentLocation.longitude,
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];
}
Error:
Method definition for ‘getCurrentLocation not found
Thanks
It looks like you haven’t written getCurrentLocation. I’m not sure what that method is but google for CoreLocationControllerDelegate, that will show you how to get your location.
Is there a reason you don’t want to use MKMapView? It really makes your life easy.