I am trying to get a map display snapshot using the startWithCompletionHandler methods for MKMapSnapshotter. and I want to add an individual annotation view for snapshots. and in my custom annotation view there is a label. therefore, I canβt show this mark when I get a snapshot. here is the code:
let snapshotter = MKMapSnapshotter(options: options) snapshotter.startWithCompletionHandler() { snapshot, error in if error != nil { completion(image: nil, error: error) return } let image = snapshot.image let pin = MKPinAnnotationView(annotation: nil, reuseIdentifier: "") // I want to use custom annotation view instead of MKPinAnnotationView let pinImage = UIImage(named: "pinImage") UIGraphicsBeginImageContextWithOptions(image.size, true, image.scale); image.drawAtPoint(CGPointMake(0, 0)) var homePoint = snapshot.pointForCoordinate(coordinates[0]) pinImage!.drawAtPoint(homePoint) pinImage!.drawAtPoint(snapshot.pointForCoordinate(coordinates[1])) let finalImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() completion(image: finalImage, error: nil) }
as you can see drawAtPoint is a UIImage function. I try to use UIImageView, then I add a shortcut to imageView as a subView, but I cannot use drawAtPoint with imageView, so my problem is that I cannot add a shortcut to the mapView snapshot.
you can see what I mean by reference: https://www.dropbox.com/s/83hnkiqi87uy5ab/map.png?dl=0
Thanks for the advice.
source share