【问题标题】:put CLLocationCoordinate2D into CLLocation for Swift将 CLLocationCoordinate2D 放入 CLLocation for Swift
【发布时间】:2015-01-08 09:45:33
【问题描述】:

我有一个我想调用的方法,但是当我回到地图中心时,它是 CLLocationCoordinate2D 类型的。

如何将 CLLocationCoordinate2D 的结果放入 CLLocation?

【问题讨论】:

    标签: ios swift mapkit cllocation cllocationcoordinate2d


    【解决方案1】:

    想通了。

    当 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)
    
    }
    

    【讨论】:

      猜你喜欢
      • 2011-01-20
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多