Tag: cllocationcoordinate2d

如何在Google Map iOS Swift中获取经纬度位置的纬度

我试图从谷歌地图视图中的挖掘位置获取CLLocationCoordinate2D对象。 但它总是以-180.0,-180.0为单位,如下所示: CLLocationCoordinate2D(latitude: -180.0, longitude: -180.0) 我正在使用以下代码: override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { let touchpoint = touches.first if let touch = touches.first { var point: CGPoint = touch.locationInView(self.view) let touchMapCoordinate: CLLocationCoordinate2D = MyMapView.projection.coordinateForPoint(point) } }

iOS Swift – CLGeocoder completionHandler块

我试图parsing一个位置(CLLocation)到一个string。 func locationToString (currentLocation: CLLocation) -> String? { var whatToReturn: String? CLGeocoder().reverseGeocodeLocation(currentLocation, completionHandler: { (placemarks: [AnyObject]!, error: NSError!) in if error == nil && placemarks.count > 0 { let location = placemarks[0] as CLPlacemark whatToReturn = "\(location.locality) \(location.thoroughfare) \(location.subThoroughfare)" } }) return whatToReturn } 显然,whatToReturn总是返回null,因为completionHandler在后台运行。 我很难理解在completionHandler完成时如何更新我的string? 谢谢。

将CLLocationCoordinate2D放入Swift的CLLocation中

我有一个方法,我想调用,但是当我回到地图的中心,它是在CLLocationCoordinate2Dtypes。 如何将CLLocationCoordinate2D的结果放入CLLocation中?