Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can get the coordinates of the current location using CLLocationManager, or its wrapper <a href="https://github.com/keithpitt/DKLocationManager" rel="nofollow">DKLocationManager</a> (on github), created by <a href="http://keithpitt.com/" rel="nofollow">Keith Pitt</a>. </p> <p>Once you have the coordinates, you can use the following code sample. </p> <pre><code>+ (void) openDirectionFrom:CLLocation* currentLocation To:(NSString*) daddr { NSString* urlStr; NSString* saddr = @"Current+Location"; if ([[UIDevice currentDevice] systemVersion] floatValue] &gt;=6) { //iOS 6+, Should use map.apple.com. Current Location doesn't work in iOS 6 . Must provide the coordinate. if ((currentLocation.coordinate.latitude != kCLLocationCoordinate2DInvalid.latitude) &amp;&amp; (currentLocation.coordinate.longitude != kCLLocationCoordinate2DInvalid.longitude)) { //Valid location. saddr = [NSString stringWithFormat:@"%f,%f", currentLocation.coordinate.latitude,currentLocation.coordinate.longitude]; urlStr = [NSString stringWithFormat:@"http://maps.apple.com/maps?saddr=%@&amp;daddr=%@", saddr, daddr]; } else { //Invalid location. Location Service disabled. urlStr = [NSString stringWithFormat:@"http://maps.apple.com/maps?daddr=%@", daddr]; } } else { // &lt; iOS 6. Use maps.google.com urlStr = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%@&amp;daddr=%@", saddr, daddr]; } [(UIApplicationWithEvents*)[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload