本文介绍了把CLLocationCoordinate2D放到Swift的CLLocation中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个我想要调用的方法,但是当我回到地图的中心时,它处于CLLocationCoordinate2D类型。
I have a method I want to call however when I get back the center of the map, it is in CLLocationCoordinate2D type.
我如何设置结果CLLocationCoordinate2D进入CLLocation?
How do I put the results of CLLocationCoordinate2D into CLLocation?
推荐答案
想出来。
当mapView更改区域,从CLLocationCoordinate2D获取Lat和Lon,并创建一个传入lat和lon的CLLocation变量。
When mapView changes region, get the Lat and Lon from CLLocationCoordinate2D and create a CLLocation variable with the lat and lon passed in.
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)
}
这篇关于把CLLocationCoordinate2D放到Swift的CLLocation中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!