簡體   English   中英

將 CLLocationCoordinate2D 放入 CLLocation for Swift

[英]put CLLocationCoordinate2D into CLLocation for Swift

我有一個我想調用的方法,但是當我回到地圖的中心時,它是 CLLocationCoordinate2D 類型。

如何將 CLLocationCoordinate2D 的結果放入 CLLocation?

弄清楚了。

當 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM