Current location does not work with Apple Maps iOS 6

Prior to iOS 6, I used this URL scheme to open a native map application and find directions from users' current location to the address I created.

http://maps.google.com/maps?daddr= "+ address +" & saddr = Current + Location

This works fine, but now that they got rid of google maps with iOS 6, we had to check which version of iOS they were included in, and then refer to the new Apple map URL scheme if they use iOS 6.0 or higher. The new URL scheme we use is ...

http://maps.apple.com/maps?daddr= "+ address +" & saddr = Current + Location

This is based on the new documentation for map URL schemes, which can be found here.

Anyway, I tested it on a bunch, and it comes down to new Apple maps that recognize the current location, like google maps.

Does anyone know how I can fix this?

Keep in mind that I am creating an html application with a gap in the phone, so using my own code to set the starting address to the current location will not help me.

+13
url-scheme ios6-maps
Sep 21 '12 at 22:33
source share
4 answers

I have the same problem. I haven't found a solution yet, but if you leave the sadir

http://maps.apple.com/maps?daddr=" + address 

he will just ask them where to start, and the first option is "Current Location", so when they click "Current Location", he will display the map correctly.

If someone finds a better solution, submit it as I'm still looking for a better solution.

+10
Sep 22
source share

You can use my method:

  <script type="text/javascript"> var link = "maps:saddr=YPlat,YPlong&daddr=42.118599,-72.625122"; navigator.geolocation.getCurrentPosition(showPosition); function showPosition(position) { link = link.replace("YPlat",position.coords.latitude); link = link.replace("YPlong",position.coords.longitude); window.location = link; } </script> 

Confirmed iOS 5.1 and iOS 6

+3
Dec 07
source share

Just pass "Current Location" as the source address:

 http://maps.apple.com/maps?saddr=Current%20Location&daddr=Your_Address 
+3
Jan 21 '15 at 1:00
source share

You can get the coordinates of your current location using the CLLocationManager or its DKLocationManager shell (on github) created by Keith Pitt .

Once you have the coordinates, you can use the following code example.

 + (void) openDirectionFrom:CLLocation* currentLocation To:(NSString*) daddr { NSString* urlStr; NSString* saddr = @"Current+Location"; if ([[UIDevice currentDevice] systemVersion] floatValue] >=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) && (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=%@&daddr=%@", saddr, daddr]; } else { //Invalid location. Location Service disabled. urlStr = [NSString stringWithFormat:@"http://maps.apple.com/maps?daddr=%@", daddr]; } } else { // < iOS 6. Use maps.google.com urlStr = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%@&daddr=%@", saddr, daddr]; } [(UIApplicationWithEvents*)[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]]; } 
+2
Jan 11 '13 at 5:30
source share



All Articles