ios输入地址得出经纬度 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

   

ios输入地址得出经纬度

CLGeocoder *myGeocoder = [[CLGeocoder alloc] init];

    [myGeocoder geocodeAddressString:_searchBar.text completionHandler:^(NSArray *placemarks, NSError *error) {

    if ([placemarks count] > 0 && error == nil) {

    CLPlacemark *firstPlacemark = [placemarks objectAtIndex:0];

    NSLog(@"%f",firstPlacemark.location.coordinate.latitude);

    NSLog(@"%f",firstPlacemark.location.coordinate.longitude);

    }

    else if ([placemarks count] == 0 && error == nil) {

    NSLog(@"Found no placemarks.");

    }

    else if (error != nil) {

    NSLog(@"An error ccurred = %@", error); } }];

最新文章