Rob
Rob

Reputation: 11733

Generate an Image from a Map in iOS

Here's what I want to do:

  1. Get some destination.
  2. Render it in the maps into a view.
  3. Turn that into an image I can then save and use as a background.

Another option would be to put a map view down, turn off all input and just paint on top of it. Basically asking for a way to rasterize the map view. Wondering if anyone has done this.

Upvotes: 0

Views: 1216

Answers (1)

rdelmar
rdelmar

Reputation: 104082

You can render any view into an image with something like this:

    UIGraphicsBeginImageContextWithOptions(mapView.bounds.size, NO, 0.0f);
    [mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

Upvotes: 4

Related Questions