0

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 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?

Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75

1 Answers1

0

I got the same issue. But I resolve it by:

  1. Enable Location service on iPhone service
  2. Open Maps on iPhone device.
  3. Back to watch and now your map will be shown!

I think problem is, watch need map data from parent device to show.

Phong Nguyen
  • 277
  • 4
  • 16
  • But that means even users shall need to have their map app open in order to show the map in my app? That would tantamount to not having any map feature at all. – Fabrizio Bartolomucci Nov 25 '15 at 14:44