WKInterfaceMap is not shown on WatchOS 2 project

I am trying to display a map in a Watch app by means of this class:

import WatchKit
class WKMapController: WKInterfaceController {
    @IBOutlet var map: WKInterfaceMap!
    let mapSpan=0.0001
    override func awakeWithContext(context: AnyObject?) {
        super.awakeWithContext(context)
        if let location = context as? CLLocation {
            NSLog("latitude \(location.coordinate.latitude) longitude \(location.coordinate.longitude)")
            let size=MKMapSize(width:mapSpan, height: mapSpan)
            let mapRect=MKMapRect(origin: MKMapPoint(x: location.coordinate.latitude-mapSpan/2, y: location.coordinate.longitude-mapSpan/2), size: size)
            let regionSpan=MKCoordinateSpan(latitudeDelta: size.width, longitudeDelta: size.height)
            let region=MKCoordinateRegionMake(location.coordinate, regionSpan)
            map.setRegion(region)
            map.setVisibleMapRect(mapRect)
        }
    }
}

This is the description of the MapRegion that should be fine:

Printing description of region: ▿ MKCoordinateRegion ▿ center : CLLocationCoordinate2D - latitude : 41.7165946960449 - longitude : 12.3110208511353 ▿ span : MKCoordinateSpan - latitudeDelta : 0.0001 - longitudeDelta : 0.0001


Yet just the blank map is displayed. How do I show the real map?

If this issue is in the Simulator, start the Maps app on the iPhone Simulator first.

The map obviously shows well in the iPhone simulator. It is in the simulated watch that is not shown.

Yes, from the following thread, was hoping that actually starting the iPhone Maps app would help render the WKInterfaceMap for you.


https://forums.developer.apple.com/message/50311#50311

It may be so, but how may I display the map on the iPhone simulator if I simulate the watch while the former is in background?

When the other post mentions start the Maps app on the iPhone, they mean manually. Just start the Maps app in the iPhone Simulator with your mouse before building/running your project from xcode.

Do you mean first installing the app on the simulator, stop it and then start the simulation of the Watch after having activate the app by clicking on the iPhone simulator?

If I do so, first the watch shows the red iPhone icon suggesting no iPhone is paired, then when executing the app on the watch, the app on the iPhone manually started is terminated and finally the watch app refuses to be installing suggesting me to check the console for that matter reporting nothing.

When saying you should start the iPhone Maps app, mean the one from Apple, not 'your maps app'. This somehow triggers the Apple Watch Simulator map to render properly.

If you are having connectivity issues, suggest looking at the Potloc sample code.

https://developer.apple.com/library/prerelease/watchos/samplecode/PotLoc/Introduction/Intro.html

Yes, in fact while I keep the map app open in the iPhone simulator, the map also shows in my app on the watch. Yet I wonder about what happens when users access the map while their iPhone is in their pocket. Is this condition just valid for testing or what else? Of course having to keep the map open to use the watch version would defy the very purpose of the watch. Also the map behaves weirdly. It shows the area of the Arctic ocean (instead of the familiar Gulf of Guinea, no two motion the area on which a set the center...) and if I click that I get message "Unknown location" with a list of Directions to select and no way to return to my app.

WKInterfaceMap is not shown on WatchOS 2 project
 
 
Q