Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open the Maps App in Apple Watch with a specific Location?

Right now, I have an Apple Watch App, that displays a map with a few locations. Playing around with my Apple Watch, I realized that if you tap on the map, it opens up the Apple Watch Maps.

My main question is, how do I set it so that, when the map is tapped, or when a button is tapped, the Apple Watch Maps opens up, displaying the destination. I know how to do this with the iPhone, but I'm not sure how it works with the Apple Watch.

like image 574
Avinash12388 Avatar asked Oct 18 '25 04:10

Avinash12388


2 Answers

If you display a map with only one location pin, when the user taps the map, it will open the map app to that location. This is the only way currently to open the map app on the watch. Confirmed by Apple in Apple Developer Forums

"There is no url to call at this time. The user tapping on a WKInterfaceMap object is the only way to launch the Maps app from yours."

Apple Dev Forums

like image 189
rmp Avatar answered Oct 19 '25 18:10

rmp


We found a way to launch the Maps app programmatically and can even override which location tapping on the Map opens (this also allows setting the name of the location). Add the following code to a function that either handles button clicks:

let center = CLLocationCoordinate2DMake(latitude, longitude)
let placemark = MKPlacemark(coordinate: center, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = "Name of location"
mapItem.openInMaps(launchOptions: nil)

To override which location tapping on a map shows, add a tap gesture recognizer to the map and put the above code in the selector function.

like image 21
nickel3956 Avatar answered Oct 19 '25 19:10

nickel3956



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!