自学Swift-斯坦福笔记整理(十四) Core Location and MapKit

Core Location
单纯的管理位置的信息
CLLocation基本对象
属性:coordinate,altitude,horizontal/verticalAccuracy,timestamp,speed,course
//维度 2D只为在地上没包含高度
var coordinate: CLLocationCoordinate2D
struct CLLocationCoordinate2D {
     CLLocationDegrees latitude
     CLLocationDegrees longitude
}
高度的变量为altitude
最高的精度叫做BestForNavigation
速度(speed)指的是瞬时速度
var speed: CLLocationSpeed
方向(course)
var course: CLLocationDirection
时间戳(Time stamp)
var timestamp: NSDate

class func authorizationStatus() -> CLAuthorizationStatus//authorized,Denied or Restricted
class func locationServicesEnabled() -> Bool//使用或不使用locations for app
class func significantLocationChangemonitoringAvailable() -> Bool
class func ismONITORINGavailableForClass(AnyClass!) -> Bool
class func isRangeingAvailable() -> Bool


func requestWhenInUseAuthorization()//只当APP启动的时候启用定位服务
func requestAlwaysAuthorization() //一直

要使用定位服务还需要在Info.plist中添加两个关键字中其中一个
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
只需要有其中一个.不需要有固定的值..只需要有key在就可以

var desiredAccuracy: CLLocationAccuracy//精确
var distanceFilter: CLLocatoinDistance//移动距离后更新位置

func startUpdatingLocation()
func stoppedatingLocation()


MapKit
MKMapView 展示一个地图
大头针是一个协议..实现协议内有三个属性coordinate 坐标,经纬度
title 和subtitle 标题和子标题
大头针通过MKAnnotationView的子类来显示的MKPinAnnotationView
import MapKit
protocol MKAnnotation: NSObject{
     var coordinate: CLLocatoinCoordinate2D {get}
     var title: String! {get}
     var subtitle: String!{get}
}
标题不能为空,副标题可为空
var annotations: [MKAnnotation] {get}
func addAnnotation(MKSnnotatiON)
func addAnnotations([MKAnnotation])
func removeAnnotation(MKAnnotation)
func removaAnnotations([MKAnnotation])
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值