CLLocationCoordinate2D

CLLocationCoordinate2D

我有一个要调用的方法,但是当我回到 map 中心时,它处于CLLocationCoordinate2D类型。

如何将CLLocationCoordinate2D的结果放入CLLocation?

最佳答案

弄清楚了。

当mapView更改区域时,从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)

}

关于ios - 将CLLocationCoordinate2D放入Swift的CLLocation中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26871750/

10-13 02:24