Xamarin iOS 7 MapKit SnapShot

A new addition to the MapKit API in iOS 7 is the MKMapSnapShotter class. This class can be used to take a snap shot of map based images. In the following example I’ll show you how to create a snap shot, and save the image to the devices photo album.

Since we covered creating a new map in an earlier post, we’ll skip that part, and dive right into the goodness!

First, you’ll need to create a new instance of MKMapSnapshotOptions, and set the region, scale, and size properties.

      using (var snapShotOptions = new MKMapSnapshotOptions())
          snapShotOptions.Region = _map.Region;
          snapShotOptions.Scale = UIScreen.MainScreen.Scale;
          snapShotOptions.Size = _map.Frame.Size;

Next, we’ll create a new instance of MKMapSnapshotter, and initialize it with the MKMapSnapshotOptions we just created.

using (var snapShot = new MKMapSnapshotter(snapShotOptions))

Finally, we need to call the start method and handle the completion handler. The handler gives us an MKSnapShop, which has an Image property. We can call the SaveToPhotosAlbum method on the Image property to store it to the device’s album.

snapShot.Start((snapshot, error) =>
                  if (error == null)
                          (uiimage, imgError) =>
                                  if (imgError == null)
                                      new UIAlertView("Image Saved", "Map View Image Saved!", null, "OK", null).Show();


The image should then be available in the device’s photo album. I have updated the MapKitDirections Sample on GitHub to include these new changes.


2 thoughts on “Xamarin iOS 7 MapKit SnapShot

  1. Hi Blake,
    I am using the same code in my application but am getting the same image every time. Initially it was working fine but now,the image is not getting changed.
    Do you have any idea what’s wrong?

  2. Hey Blake ,

    I am using the same code in my application and evrything was working fine. But from last few days, am facing one issue, now when i take snapshot of my map view,i am getting the same image everytime. I checked devicd photos album, same image is being saved for multiple times.
    Can you please help me out.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s