百度地图SDK
判断定位是否打开
func locationIsOpen() -> Bool {
if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.denied {
let vc = UIAlertController.init(title: "未开通定位权限", message: "请到设置中开通定位权限", cancelTitle: "取消", otherTitles: ["确定"], style: .alert) { (_) in
}
self.present(vc, animated: true, completion: nil)
return false
} else {
return false
}
}
转为百度经纬度类型的坐标
let bd09Coord = BMKCoordTrans(coordinate, BMK_COORD_TYPE.COORDTYPE_GPS, BMK_COORD_TYPE.COORDTYPE_BD09LL);
让气泡直接显示
mapView.selectAnnotation(annotation, animated: true)
// 取出本地保存的围栏坐标
let dict = UserDefaults.standard.dictionary(forKey: "FenceCoordinate") as? [String : String]
if let latitude = dict?["latitude"], let longitude = dict?["longitude"] {
circleCoordinate = CLLocationCoordinate2D(latitude: Double(latitude) ?? 0, longitude: Double(longitude) ?? 0)
}
网友评论