Getting the bounds of an MKMapView

Okay I officially answered my own question but since I didn’t find it anywhere before I’ll post the answer here: //To calculate the search bounds… //First we need to calculate the corners of the map so we get the points CGPoint nePoint = CGPointMake(self.mapView.bounds.origin.x + mapView.bounds.size.width, mapView.bounds.origin.y); CGPoint swPoint = CGPointMake((self.mapView.bounds.origin.x), (mapView.bounds.origin.y + mapView.bounds.size.height)); //Then … Read more

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

iOS 8 Map Kit Obj-C Cannot Get Users Location

I got it working. I’ve posted my code below to help anyone else having issues. Here is my full code to get the MapKit Map View working in iOS 8. In your AppName-Info.plist Add a new row with the key name being: NSLocationWhenInUseUsageDescription Or NSLocationAlwaysUsageDescription With the value being a string of the message that … Read more

VectorKit crash reports with MKMapSnapshotter on iOS

How repeatable is this? Is the device coming out of sleep mode? What is on the screen when the App goes into the background? Within the ViewController you can try registering the NSNotification event, UIApplicationWillResignActiveNotification When the App is going into the background, calling cancel on any MKMapSnapshotter If that doesn’t work, you could attempt … Read more

Convert coordinates to City name?

SWIFT 4.2 : EDIT MapKit framework does provide a way to get address details from coordinates. You need to use reverse geocoding of map kit. CLGeocoder class is used to get the location from address and address from the location (coordinates). The method reverseGeocodeLocation will returns the address details from coordinates. This method accepts CLLocation … Read more

Drawing a route in MapKit in iOS

The following viewDidLoad will (1) set two locations, (2) remove all the previous annotations, and (3) call user defined helper functions (to get route points and draw the route). -(void)viewDidLoad { [super viewDidLoad]; // Origin Location. CLLocationCoordinate2D loc1; loc1.latitude = 29.0167; loc1.longitude = 77.3833; Annotation *origin = [[Annotation alloc] initWithTitle:@”loc1″ subTitle:@”Home1″ andCoordinate:loc1]; [objMapView addAnnotation:origin]; // … Read more

MKMapView Zoom and Region

First of all, MKMapView does not use/have a predefined set of zoom levels like Google Maps does. Instead, the visible area of a MKMapView is described using MKCoordinateRegion, which consists of two values: center (the center point of the region), and span (the size of the visible area around center). The center point should be … Read more

How to customize the callout bubble for MKAnnotationView?

There is an even easier solution. Create a custom UIView (for your callout). Then create a subclass of MKAnnotationView and override setSelected as follows: – (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; if(selected) { //Add your custom view to self… } else { //Remove your custom view… } } Boom, job done.