美文网首页
输入地址得到经纬度

输入地址得到经纬度

作者: _wxx | 来源:发表于2016-04-26 15:15 被阅读41次
    需要集成百度地图
    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 occurred = %@", error); 
    } }];
    

    相关文章

      网友评论

          本文标题:输入地址得到经纬度

          本文链接:https://www.haomeiwen.com/subject/clgqrttx.html