zoukankan      html  css  js  c++  java
  • iOS定位服务CoreLocation


    欢迎訪问我的新博客: 开发人员说


    基于LBS的应用开发是当今移动开发中的一大热门, 当中主要涉及到地图和定位两个方面.

    iOS开发中, 定位服务依赖于CoreLocation框架, CLLocationManager是CoreLocation中的核心类.

    初始化:

    if ([CLLocationManagerlocationServicesEnabled]) {

                self.locationManager = [[CLLocationManageralloc]init];

                self.locationManager.delegate =self;

                self.locationManager.desiredAccuracy =kCLLocationAccuracyBest;

                self.locationManager.distanceFilter =kDistanceFilter;

                self.locationManager.headingFilter =kHeadingFilter;

                self.locationManager.pausesLocationUpdatesAutomatically =YES;

                self.locationManager.activityType =CLActivityTypeFitness;

            }


    desiredAccuracy: 想要获得的定位精度, 会尽可能地满足设定的精度, 但不能保证在实际过程中能达到.

    distanceFilter: 低于水平距离会过滤掉而不产生更新事件.


    開始定位服务:

    [self.locationManagerstartUpdatingLocation];

    [self.locationManagerstartUpdatingHeading];


    当获取到位置信息或位置产生变化时会通知代理

    获取到新的位置:

    locationManager:didUpdateLocations

    方向产生变化时:

    locationManager:didUpdateHeading:


    很多其它内容请訪问: devsay.com

  • 相关阅读:
    webservice理解
    什么是xmlschema
    web项目中的跨域问题解决方法
    浏览器的同源策略和跨域问题
    java中Scanner和random的用法
    mybatis的批量删除
    java中的异常理解
    事务回滚
    做人做事2个字:心、眼
    Linux下找不到so文件的解决办法
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/7279217.html
Copyright © 2011-2022 走看看