IOS map Development Summary
First, the main types used for ios map development are as follows:
MKMapView: map control. It can be used when it is dragged in without any other labels. It is used to display the map content, you can zoom in, zoom out, drag, or rotate a map;
CLLocationCoordinate2D: coordinates, including longitude and latitude;
MKCoordinateSpan: Map span, indicating a map magnification. The smaller the value, the finer the unit displayed on the map;
CLLocationManager: The management class of the user's location. This class can be used to obtain the GPS coordinates of the user.
Below we will share with you some of the knowledge involved in the map part of my personal projects, which are all entry-level. Please bypass this:
1. Map Display
The Map Display captures two elements: the center coordinate point and the map span. If the coordinate center is (0, 0) and the span is (8, 6), the display range of the map is [-4,-3] to [4, 3]. The Code is as follows:
// Set the center coordinate point CLLocationCoordinate2D curLocation; curLocation. latitude = 23.9098099; curLocation. longpolling = 112.980980; // set the map span MKCoordinateSpan span; span. latitudeDelta = 0.008; span. longitudeDelta = 0.008; // display the map MKCoordinateRegion region = {curLocation, span}; [self. mapView setRegion: region animated: NO];As shown in the Code, after setting the central coordinate point and map span, call setRegion to display the map. The animated parameter indicates whether to use an animation when displaying the map.
2. Positioning
How can we get our current location and display it on a map?
The CLLocationManager mentioned above is used in three steps.
Step 1: Enable the app positioning function:
If (self. locationManager = nil) {self. locationManager = [[CLLocationManager alloc] init]; self. locationManager. delegate = self; self. locationManager. desiredAccuracy = kCLLocationAccuracyBest; self. locationManager. distanceFilter = 1000.0; NSLog (@ "response