我有一个想要调用的方法,但是当我获取地图中心时,它以"CLLocationCoordinate2D"类型返回。
如何将"CLLocationCoordinate2D"的结果放入"CLLocation"中?
我有一个想要调用的方法,但是当我获取地图中心时,它以"CLLocationCoordinate2D"类型返回。
如何将"CLLocationCoordinate2D"的结果放入"CLLocation"中?
明白了。
当地图视图改变区域时,从CLLocationCoordinate2D获取纬度和经度,并使用传入的纬度和经度创建一个CLLocation变量。
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)
}