0

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

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
Seb
  • 53
  • 10

1 Answers1

0

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.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
  • Thanks for the reply, how would I write 'getCurrentLocation'? – Seb Mar 07 '12 at 06:21
  • you would google CoreLocationControllerDelegate, find a tutorial, follow the steps there. – Paul Cezanne Mar 07 '12 at 13:05
  • In the end I just used the CLLocationManager and linked a Latitude and Longitude to a string and made the starting address that string. Thanks for the help though! – Seb Jun 02 '12 at 08:44