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

  • 相关阅读:
    UNIX网络编程总结三
    UNIX网络编程总结二
    UNIX网络编程总结一
    KVM
    nginx+flask+gevent+uwsgi实现websocket
    Hypervisor
    JBPM4入门——4.封装流程管理的工具类(JbpmUtil)
    JBPM4入门——3.JBPM4开发环境的搭建
    JBPM4入门——2.在eclipse中安装绘制jbpm流程图的插件
    JBPM4入门——1.jbpm简要介绍
  • 原文地址:https://www.cnblogs.com/yk00/p/2964053.html
Copyright © 2011-2022 走看看