When I try to copy an MKMapView with eg a track as overlay only the map image is copied. This is my current code used
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.declareTypes([NSPasteboard.PasteboardType.png], owner: self)
let rect = mapView.visibleRect
let rep = mapView.bitmapImageRepForCachingDisplay(in: rect)
mapView.cacheDisplay(in: rect, to: rep!)
pasteboard.setData(rep?.representation(using: NSBitmapImageRep.FileType.png, properties: [:]), forType: NSPasteboard.PasteboardType.png)
Expected result: Mapview image with all overlays Actual
result: only map
I also tried writePDFinsdeRect, but then only the legend is copied into the NSPasteboard.
I guess I'm missing something here.