将CLLocationCoordinate2D放入Swift的CLLocation中
我有一个方法,我想调用,但是当我回到地图的中心,它是在CLLocationCoordinate2Dtypes。
如何将CLLocationCoordinate2D的结果放入CLLocation中?
弄清楚了。
当mapView改变区域时,从CLLocationCoordinate2D获得Lat和Lon,并创build一个CLLocationvariables,经过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) }