CoreLocation MKMapView map, corelocation
Built-in Map Framework: CoreLocation MapKit
CLLocationManager --> positioning manager CLGeocoder --> geographic encoder MKMapView --> map view
Allow user location
[_ LocationManager requestAlwaysAuthorization]; // always allow
[_ LocationManager requestWhenInUseAuthorization]; // allow
The location proxy method is called again only when the user moves 100 meters.
_ LocationManager. distanceFilter = 100.0;
Start locating
[_ LocationManager startUpdatingLocation];
CLLocationManager proxy method: (obtain the information room for processing)
-(Void) locationManager :( CLLocationManager *) manager didUpdateLocations :( NSArray <CLLocation *> *) locations {
}
At which point the proportional coefficient is displayed
MKCoordinateRegion region = MKCoordinateRegionMake (userLocation. coordinate, MKCoordinateSpanMake (0.1, 0.1 ));
Proportional Coefficient Assignment
_ MapView. region = region;
CLGeocoder:
Encoding:Provide a string to locate the location:-(void) geocodeAddressString :( NSString *) addressString completionHandler :( CLGeocodeCompletionHandler) completionHandler;
Anti-encoding:Display the name of the location Based on the location. [_ geocoder handler: placemark. location completionHandler: ^ (NSArray <CLPlacemark *> * _ Nullable placemarks, NSError * _ Nullable error) {}];
Add pin:
AGAnnotion * agAnnotion = [[AGAnnotion alloc] init];
AgAnnotion. coordinate = CLLocationCoordinate2DMake (36.0, 120.0 );
AgAnnotion. title = @ "coco ";
[_ MapView addAnnotation: agAnnotion];
Custom bubble
Inherit NSObject and follow MKAnnotation Protocol
Create three attributes
@ Property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@ Property (nonatomic, copy) NSString * title;
@ Property (nonatomic, copy) NSString * subtitle;
Autonavi:
1. Verify the key
[MAMapServices sharedServices]. apiKey = @ "applied key ";
2. Initialization
MapView = [[MAMapView alloc] initWithFrame: CGRectMake (0, 0, CGRectGetWidth (self. view. frame), CGRectGetHeight (self. view. bounds)];
MapView. delegate = self;
MapView. language = MAMapLanguageEn; // sets the Map Display language.
MapView. mapType = MAMapTypeStandard; // map type
/*
MAMapTypeSatellite: Satellite Map
MAMapTypeStandard: Standard Map
*/
MapView. showTraffic = YES; // display real-time traffic conditions
[Self. view addSubview: mapView];
MapView. showsUserLocation = YES;
Location mode of mapView: userTrackingMode
MAUserTrackingModeNone: displays only on the map without following the user's location.
MAUserTrackingModeFollow: follows the user's position and sets the positioning point to the map center point.
MAUserTrackingModeFollowWithHeading: follows the user's location and Angle
Differences between the system map and AMAP