Want to get current location to work?
Here's how.
I've recently been plugging away at the contact section of the "soon to be launched" app for Our Daily Bread. By the way, they have some stellar cookies and baked goods! You should definitely check them out. At any rate, I wanted to share with some of you how to use Current Location in the Maps app for iOS. There is a very tedious way to go about it using the CoreLocation framework and CLLocationManager. However, if you just want the app to open up the maps app, and give directions to the user using their current location, it is very simple.
Take a look at my example below.
- (IBAction)directions1_click:(id)sender
{
NSString* address = @"118 S. Main St., Fitzgerald, GA,31750";
NSString* currentLocation = @"Current Location";
NSString* url = [NSStringstringWithFormat: @"http://maps.google.com/maps?saddr=%@&daddr=%@",[currentLocation stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
UIApplication *app = [UIApplicationsharedApplication];
[app openURL: [NSURL URLWithString: url]];
}
Once you link your objects in Interface Builder to the button and it's event, you should receive the following screen (depending on your destination, of course).

If you appreciate this article, please like us on Facebook.