网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

MapView的应用-创新互联

MapView在8.0之后,用法有了一些新的用法(代理方法),在此之前需要导入

成都创新互联是一家专注于成都网站制作、做网站与策划设计,蒲江县网站建设哪家好?成都创新互联做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:蒲江县等地区。蒲江县做网站价格咨询:18980820575

#import

//创建位置服务对象

  locationManager = [[CLLocationManager alloc] init];

 

  locationManager.desiredAccuracy = kCLLocationAccuracyBest;

 

  //设置定位代理

  locationManager.delegate = self;

 

  //如果实在iOS8.0之后,我们需要添加以下操作

  //1.调用方法--requestWhenInUseAuthorization 或者 requestAlwaysAuthorization

  //2.

 

  if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {

      [locationManager requestWhenInUseAuthorization];

  }

 

  //开始定位

  [locationManager startUpdatingLocation];

 

 

}

- (void)didReceiveMemoryWarning {

  [super didReceiveMemoryWarning];

  // Dispose of any resources that can be recreated.

}

#pragma mark -CLLocationManagerDelegate

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

{

  NSLog(@"定位成功");

  //停止定位

  [locationManager stopUpdatingLocation];

 

  CLLocationCoordinate2D coordinate = newLocation.coordinate;

 

  NSLog(@"位置:纬度:%.2f----经度:%.2f", coordinate.latitude, coordinate.longitude);

 

}

- (void)locationManager:(CLLocationManager *)manager

    didUpdateLocations:(NSArray *)locations

{

  NSLog(@"新方法定位成功");

  //停止定位

  [locationManager stopUpdatingLocation];

 

  CLLocation *location = [locations lastObject];

 

  CLLocationCoordinate2D coordinate = location.coordinate;

  NSLog(@"位置:纬度:%.2f----经度:%.2f", coordinate.latitude, coordinate.longitude);

 

  //在iOS5.0之前使用位置反编码

  MKReverseGeocoder *mkReverse = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate];

  mkReverse.delegate = self;

  //开始反编码

  [mkReverse start];

 

 

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

  [geocoder reverseGeocodeLocation:location

                  completionHandler:^(NSArray *placemarks, NSError *error) {

                   

                      NSLog(@"---------CLGeocoder---------------");

                   

                   

                      for (CLPlacemark *place in placemarks) {

                          NSLog(@"name,%@",place.name);                       // 位置名

                          NSLog(@"thoroughfare,%@",place.thoroughfare);       // 街道

                          NSLog(@"subThoroughfare,%@",place.subThoroughfare); // 子街道

                          NSLog(@"locality,%@",place.locality);               // 市

                          NSLog(@"subLocality,%@",place.subLocality);         // 区

                          NSLog(@"country,%@",place.country);                 // 国家

                      }

                  }

    ]; // CLGeocoder反编码

 

 

}

#pragma mark -MKReverseGeocoderDelegate

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)place

{

 

  NSLog(@"-----------MKReverseGeocoderDelegate----------");

  NSLog(@"name,%@",place.name);                       // 位置名

  NSLog(@"thoroughfare,%@",place.thoroughfare);       // 街道

  NSLog(@"subThoroughfare,%@",place.subThoroughfare); // 子街道

  NSLog(@"locality,%@",place.locality);               // 市

  NSLog(@"subLocality,%@",place.subLocality);         // 区

  NSLog(@"country,%@",place.country);                 // 国家

}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error

{

  NSLog(@"error is %@", error);

}

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


本文标题:MapView的应用-创新互联
文章转载:http://bjjierui.cn/article/dhgjgc.html

其他资讯