简体   繁体   中英

Regarding Map Kit in iOS 6.0.1

在此处输入图片说明 I am not able to get my current location in iOS 6.0.1, ![Please see the screen shot when I am trying to get my current location the map view is not showing it just show blank map screen my current location latitude longitude both are correct

My code is as below:-

  //Start fetching logged in user current location
    self.m_LocationManager = [[CLLocationManager alloc] init];
    self.m_LocationManager.distanceFilter = kCLDistanceFilterNone;
    self.m_LocationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    self.m_LocationManager.delegate = self;

    [self.m_LocationManager startUpdatingLocation];

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    [manager stopUpdatingLocation];

    self.m_LatitudeValue = newLocation.coordinate.latitude;
    self.m_LongitudeValue = newLocation.coordinate.longitude;

    NSLog(@"lat %f long %f",self.m_LatitudeValue,self.m_LongitudeValue);
}


//for showing current location

- (void)addAnnotations { 

    MKCoordinateSpan span;
    span.latitudeDelta=0.08;
    span.longitudeDelta=0.08;


    Social_Check_InAppDelegate *appDelegate = (Social_Check_InAppDelegate *)[[UIApplication sharedApplication] delegate];

    //user current location
        double latitudeValue = appDelegate.m_LatitudeValue;
        double longitudeValue = appDelegate.m_LongitudeValue;



    CLLocationCoordinate2D coardinate1 = {latitudeValue,longitudeValue};
    MKCoordinateRegion region;
    region.center=coardinate1;
    region.span=span;

    CSMapAnnotation *ann = [[CSMapAnnotation alloc]initWithCoordinate:coardinate1];
    ann.title = m_PlacesNameString;
    ann.type = @"green";

    [m_MapView setRegion:region animated:TRUE];
    [m_MapView regionThatFits:region];
    [m_MapView addAnnotation:ann];

    [ann release];
}

Above code for showing cure

this is probably because iOS 6 does not support

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 

method. please check the documentation . Above method is deprecated. In iOS 6 and later, the location manager reports events to the locationManager:didUpdateLocations: method of its delegate when they become available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM