IOS-use MapKit and CoreLocation to implement mobile devices (MAP and location)

Source: Internet
Author: User

We found that map and location functions are introduced in many social software. If we want to implement these two functions, we need to use two frameworks: Let's first look at the frameworks: and the frameworks:

               [_mapView setUserTrackingMode:MKUserTrackingModeFollow];

 

 

Map type You can set the map type MKMapTypeStandard common map MKMapTypeSatellite satellite cloud map by setting the mapViewType of MKMapView. The MKMapTypeHybrid common map covers the satellite cloud map.
     [_mapView setMapType:MKMapTypeHybrid];

 

 

2.2.1.mapViewWillStartLoadingMap: called when the map interface is to be loaded

 

2.2.2.mapView: viewForAnnotation: called when a pin is displayed on the local graph.

 

2.2.3.mapViewWillStartLocatingUser: called when a location is to be located.

 

2.2.4.mapView: regionDidChangeAnimated: called when the display area changes

      _mapView. = self;

 

Mark-map proxy method mark is frequently called, which is very expensive-() mapView :( MKMapView *) mapView didUpdateUserLocation :( MKUserLocation * sets the map display area

CLLocationCoordinate2D center = userLocation. location. coordinate;

 
 

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance (center, 100.0, 100.0 );

 

 

 

[MapView setRegion: region animated: YES];

 

 

1. you can add a pin to the map through the addAnnotation method of MapView. you can add multiple pins to the map by using the addAnnotations method of MapView. 4. indicates that an object that complies with the MKAnnotation Protocol needs to be input.
     MyAnnotation *annotation2 =     annotation2.coordinate = CLLocationCoordinate2DMake(,      annotation2.title =      annotation2.subtitle =      annotation2.imageName = ;
     [_mapView addAnnotation:annotation2];

 

Mark custom pin view-(MKAnnotationView *) mapView :( MKMapView *) mapView viewForAnnotation :( <MKAnnotation> (! [Annotation comment: [MyAnnotation NSString * ID = MKAnnotationView * annoView = (annoView = annoView. Comment = annoView. annotation = MyAnnotation * anno = annoView. image = NSLog (}

 

       CLLocationManager *    CLGeocoder          *_geocoder;

 

 

 

 

 

LocationServicesEnabled

           (!         NSLog(               

 

 

[_ LocationManager startUpdatingLocation];

 

 

 - ()locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *      NSLog(, locations[               [_geocoder reverseGeocodeLocation:locations[] completionHandler:^(NSArray *placemarks, NSError *                  NSLog(, placemarks[           }

 

 

 

 

 

    [_geocoder geocodeAddressString: completionHandler:^(NSArray *placemarks, NSError *                   (CLPlacemark *placemark              NSLog(, placemark, (unsigned                }];

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.