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正则表达式校验密码必须是包含大小写字母、数字、特殊符号的8位以上组合
    ActiveMQ入门
    枚举的使用
    SSM整合
    springmvc 狂神说的详细笔记
    狂神说Java Mybatis笔记
    Spring5入门基础知识
    Ajax的使用详解
    Filter 过滤器的使用详解
    mysql备份与恢复命令
  • 原文地址:https://www.cnblogs.com/yk00/p/2964053.html
Copyright © 2011-2022 走看看