MKMapView slabs not loaded with zoom

I have a problem. I use MKMapView to display some annotations. I initialize the map display with default scaling. And it displays some map.

enter image description here

but when I try to scale, the tiles do not load and the map becomes empty. Like this.

enter image description here

I create my map view through the interface constructor.

 @property (nonatomic, weak) IBOutlet MKMapView* mapView; 

What am I doing wrong? Are there any mandatory implementation methods that affect this functionality? And yes, my device has an Internet connection.

+6
source share
2 answers

This can usually be due to an internet connection. If you have a slow internet connection, it takes time to download map fragments.

About the methods that I recommended overriding below.

Override MKMapView delegate method -

 - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated 

It will be called every time you zoom in / out and load map fragments.

PS - provide MKMapViewDelegate your view controller.

+1
source

I had the same download problem until I had a problem working with googling!

Note Effective ios 8 and later, we need to add the NSLocationWhenInUseUsageDescription value to the Info.plist file with our own value as a description. This is because the showsUserLocation **MKMapView** property does not work right away. More details here !!!!

 //This should be declared in .h file @property(nonatomic, strong) CLLocationManager *locationManager; - (void)viewDidLoad { self.mapView.showsUserLocation = YES; self.mapView.delegate = self; self.locationManager.delegate = self; self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.distanceFilter = kCLDistanceFilterNone; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; #ifdef __IPHONE_8_0 if(IS_OS_8_OR_LATER) { [self.locationManager requestWhenInUseAuthorization]; } #endif [self.locationManager startUpdatingLocation]; self.locationManager.distanceFilter = kCLDistanceFilterNone; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; } - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) { self.mapView.showsUserLocation = YES; } } - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { MKCoordinateRegion region; region.center = self.locationView.userLocation.coordinate; MKCoordinateSpan span; span.latitudeDelta = 0.015; ->Adjust this value to zoom as per your requirement span.longitudeDelta = 0.015; region.span = span; [self.mapView setRegion:region animated:YES]; } 

I firmly believe that this will lead to the expected result without failures, i.e. MKMapView will increase the user's current location.

-3
source

Source: https://habr.com/ru/post/976704/


All Articles