Регион карты расположен для расположения пользователя, а не для пользовательского расположения

Ну, это действительно глупый вопрос и сбивает с толку. Я пытаюсь заставить карту охватывать и фокусироваться на определенном регионе, поэтому я установил местоположение как Userlocation, это идеально.

Хотя, когда я сохраняю местоположение пользователя и пытаюсь загрузить его в viewDidLoad, это не работает.

    - (IBAction)GetcurrentLocation1:(id)sender{


    Maplocation.showsUserLocation=YES;
    MKCoordinateRegion mapRegion;
    mapRegion.center = Maplocation.userLocation.coordinate;
    NSLog(@"The USer Location are :%f %f",Maplocation.userLocation.coordinate.latitude,Maplocation.userLocation.coordinate.longitude);
    mapRegion.span.latitudeDelta = 0.2;
    mapRegion.span.longitudeDelta = 0.2;
    self.currentProduct.shop.longcoordinate=Maplocation.userLocation.coordinate.longitude;
    self.currentProduct.shop.latcoordinate=Maplocation.userLocation.coordinate.latitude;
    [Maplocation setRegion:mapRegion animated: YES];
}

    -(void)showtheuseronmap:(double)longtitude:(double)latitude{
        if(!annotation){
            annotation =[[MyAnotation alloc]initWithCoordinate:CLLocationCoordinate2DMake(latitude, longtitude) title:[self.currentProduct.shop shopname] subtitle:@"The shop is here"];
        }
        [Maplocation addAnnotation:annotation];
        MKCoordinateRegion mapRegion;
        CLLocationCoordinate2D locationsh=CLLocationCoordinate2DMake(latitude, longtitude);
        mapRegion.center=locationsh;
        NSLog(@"The USer Location are :%f",mapRegion.center.latitude);
        mapRegion.span.latitudeDelta= 0.2;
        mapRegion.span.longitudeDelta= 0.2;
        [Maplocation setRegion:mapRegion animated:YES];

        //Maplocation.showsUserLocation=YES;





    }

в viewDidLoad

[self showtheuseronmap:self.currentProduct.shop.longcoordinate :self.currentProduct.shop.latcoordinate];

в NSLog я могу видеть координаты правильно.

Я действительно смущен, я не знаю, как это может произойти?

0 ответов

Другие вопросы по тегам