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

  • 相关阅读:
    前端几个常用简单的开发手册拿走不谢
    初中级前端开发工程师如何提升个人能力?
    初中级前端开发工程师如何提升个人能力?
    【程序人生】那些工作之外的技术挣钱方式
    Java EE (13) -- 常用的基础结构模式
    3、数据类型
    洛谷——P2299 Mzc和体委的争夺战
    codevs——T1214 线段覆盖
    洛谷——P1106 删数问题
    洛谷——P1031 均分纸牌
  • 原文地址:https://www.cnblogs.com/yk00/p/2964053.html
Copyright © 2011-2022 走看看