[英]put CLLocationCoordinate2D into CLLocation for Swift
I have a method I want to call however when I get back the center of the map, it is in CLLocationCoordinate2D type.我有一个我想调用的方法,但是当我回到地图的中心时,它是 CLLocationCoordinate2D 类型。
How do I put the results of CLLocationCoordinate2D into CLLocation?如何将 CLLocationCoordinate2D 的结果放入 CLLocation?
Figured it out.弄清楚了。
When mapView changes region, get the Lat and Lon from CLLocationCoordinate2D and create a CLLocation variable with the lat and lon passed in.当 mapView 更改区域时,从 CLLocationCoordinate2D 中获取 Lat 和 Lon,并创建一个 CLLocation 变量,并传入 lat 和 lon。
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool){
var centre = mapView.centerCoordinate as CLLocationCoordinate2D
var getLat: CLLocationDegrees = centre.latitude
var getLon: CLLocationDegrees = centre.longitude
var getMovedMapCenter: CLLocation = CLLocation(latitude: getLat, longitude: getLon)
self.lastLocation = getMovedMapCenter
self.fetchCafesAroundLocation(getMovedMapCenter)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.