zoukankan      html  css  js  c++  java
  • LocationManager操作

    CLLocationManager *locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self; //You must create an object that conforms to the CLLocationManagerDelegate protocol and assign it as the location manager’s delegate.
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;

    locationManager.distanceFilter = 1000.0f; //Setting the Distance Filter ,locationManager.distanceFilter = kCLDistanceFilterNone;

    [locationManager startUpdatingLocation];

    [locationManager stopUpdatingLocation];

    The Location Manager Delegate: 

    The location manager delegate must conform to the CLLocationManagerDelegate protocol, which defines two methods, both of which are optional. One of these methods is called by the location manager when it has determined the current location or when it detects a change in location. The other method is called when the location manager encounters an error.

     Getting Location Updates:

    calls
    the locationManager:didUpdateToLocation:fromLocation: method. This method takes
    three parameters:
    The first parameter is the location manager that called the method.
    The second parameter is a CLLocation object that defines the current
    location of the device.
    The third parameter is a CLLocation object that defines the previous
    location from the last update.
    The first time this method is called, the previous location object will be nil.

    Getting Latitude and Longitude Using CLLocation:

    CLLocationDegrees latitude = theLocation.coordinate.latitude; //
    CLLocationDegrees longitude = theLocation.coordinate.longitude;

    CLLocationDistance altitude = theLocation.altitude;//how many meters above or below sea level you are:

    CLLocationDistance distance = [fromLocation distanceFromLocation:toLocation];//The code will return the distance between two CLLocation objects,fromLocation and toLocation

    Error Notifications:

    locationManager:didFailWithError

  • 相关阅读:
    你真的理解正则修饰符吗?
    一个简单易用的容器管理平台-Humpback
    【译】参考手册-React组件
    【译】快速起步-组件与属性
    css可应用的渐进增强新特性
    javascript编程杂记
    ES6模块的import和export用法总结
    对于未来chrome80 samesite问题的兼容解决方案
    mogodb数据库简单的权限分配
    egg.js npm start 启动报错
  • 原文地址:https://www.cnblogs.com/yk00/p/2964053.html
Copyright © 2011-2022 走看看