zoukankan      html  css  js  c++  java
  • 地理编码与反地理编码

    #import "ViewController.h"

    #import <CoreLocation/CoreLocation.h>

     

    @interface ViewController ()

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        //地理编码

        [self geocoder:nil];

        //反地理编码;

    }

     

    //没联网,没办法执行

    -(void)geocoder:(UIButton*)sender

    {

        //初始化地理编码类

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

        //开始地理编码

        [geo geocodeAddressString:@"北京" completionHandler:^(NSArray *placemarks, NSError *error) {

           if(placemarks.count==0||error)

               NSLog(@"%@",error) ;

            for (CLPlacemark *mark in placemarks) {

                NSLog(@"%f ,%f ,%@, %@",mark.location.coordinate.latitude,mark.location.coordinate.longitude,mark.name, mark.description);

            }

        }];

        

        NSLog(@"===");

    }

    //反地理编码

    -(void)diGeoCoder

    {

        CLLocation *location=[[CLLocation alloc]initWithLatitude:38.1 longitude:116];

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

        [geo reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {

            for (CLPlacemark *mark in placemarks) {

                NSLog(@"%f ,%f ,%@, %@",mark.location.coordinate.latitude,mark.location.coordinate.longitude,mark.name, mark.description);

            }

     

        }];

    }

  • 相关阅读:
    关于ping github.com超时的解决办法
    git使用过程中的若干问题笔记
    PAT甲级1017题解——模拟排序
    第七章4
    第七章3
    第七章2
    第七章1
    第六章4
    第六章3
    第六章2
  • 原文地址:https://www.cnblogs.com/tangranyang/p/4655618.html
Copyright © 2011-2022 走看看