How to use MKSnapshotter in Swift (iOS) -


i trying implement mksnapshotter mapkit. want create snapshot of location finding in mapview (streetview) using apple maps.

here code have far:

    var options: mkmapsnapshotoptions = mkmapsnapshotoptions();     options.region = self.attractiondetailmap.region;     options.size = self.attractiondetailmap.frame.size;     options.scale = uiscreen.mainscreen().scale;      var fileurl:nsurl = nsurl(fileurlwithpath: "path/to/snapshot.png")!;     var snapshotter:mkmapsnapshotter = mkmapsnapshotter();     snapshotter.startwithcompletionhandler { (snapshot:mkmapsnapshot!, error:nserror!) -> void in         if(error != nil) {             println("error: " + error.localizeddescription);             return;         }         var image:uiimage = snapshot.image;         var data:nsdata = uiimagepngrepresentation(image);         data.writetourl(fileurl, atomically: true);          var pin:mkannotationview = mkannotationview();         uigraphicsbeginimagecontextwithoptions(image.size, true, image.scale);         image.drawatpoint(cgpointmake(0.0, 0.0));         var rect:cgrect = cgrectmake(0.0, 0.0, image.size.width, image.size.height);         annotation in self.attractiondetailmap.annotations {             var point:cgpoint = snapshot.pointforcoordinate(annotation.coordinate);         }     } 

when try make point (var point:cgpoint = snapshot.pointforcoordinate(annotation.coordinate);), error: 'coordinate' unavailable: apis deprecated of ios7 , earlier unavailable in swift appears.

basically, since there aren't many tutorials/guidelines how use mksnapshotter in swift, it'd appreciated if see standard structure of mksnapshotter in swift. feel on right path, stuck @ last line of code, frankly doesn't work.

thanks!

you need cast annotations correct type.

for annotation in self.attractiondetailmap.annotations as! [mkannotation] {     let point = snapshot.pointforcoordinate(annotation.coordinate) } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -