Snapshot of MKMapView in iOS7

You can use MKMapSnapshotter and grab the image from the resulting MKMapSnapshot. See the discussion of it WWDC 2013 session video, Putting Map Kit in Perspective. For example: MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init]; options.region = self.mapView.region; options.scale = [UIScreen mainScreen].scale; options.size = self.mapView.frame.size; MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options]; [snapshotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *error) … Read more

Setting the zoom level for a MKMapView

I found myself a solution, which is very simple and does the trick. Use MKCoordinateRegionMakeWithDistance in order to set the distance in meters vertically and horizontally to get the desired zoom. And then of course when you update your location you’ll get the right coordinates, or you can specify it directly in the CLLocationCoordinate2D at … Read more

How to keep data associated with MKAnnotation from being lost after a callout pops up and user taps disclosure button?

In the showPinDetails: method, you can get the currently selected annotation from the map view’s selectedAnnotations property. That property is an NSArray but since the map view only allows one annotation to be selected at a time, you would just use the object at index 0. For example: – (void)showPinDetails:(id)sender { if (mapView.selectedAnnotations.count == 0) … Read more

Calculating tiles to display in a MapRect when “over-zoomed” beyond the overlay tile set

Imagine that the overlay is cloud cover – or in our case, cellular signal coverage. It might not “look good” while zoomed in deep, but the overlay is still conveying essential information to the user. I’ve worked around the problem by adding an OverZoom mode to enhance Apple’s TileMap sample code. Here is the new … Read more

Replace icon pin by text label in annotation?

Yes, it’s possible. In iOS MapKit, you’ll need to implement the viewForAnnotation delegate method and return an MKAnnotationView with a UILabel added to it. For example: -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; static NSString *reuseId = @”reuseid”; MKAnnotationView *av = [mapView dequeueReusableAnnotationViewWithIdentifier:reuseId]; if (av == nil) { av = [[[MKAnnotationView … Read more

Why am I crashing after MKMapView is freed if I’m no longer using it?

This is because of the way MKMapView works. There’s an operation pending, so MapKit is retaining the MKMapView and it hasn’t actually been deallocated yet. That isn’t itself a problem. The problem is that it’s still sending messages to your delegate. The workaround is simple: As part of your view controller’s cleanup set the map … Read more