草庐IT

LocationManager

全部标签

ios - Swift 2 – 无法使用 CLLocationManager 获取用户位置

这是我的VC代码:importUIKitimportMapKitimportCoreLocationclassViewController:UIViewController,MKMapViewDelegate,CLLocationManagerDelegate{@IBOutletweakvarmapView:MKMapView!letlocationManager=CLLocationManager()overridefuncviewDidLoad(){super.viewDidLoad()locationManager.delegate=selflocationManager.req

ios - 位置更新的时间间隔更短

我的应用程序高度基于CLLocation时间戳。我发现CLLocationManager以~1s的间隔更新位置。这对我的应用程序来说还不够。是否可以配置CLLocationManager以更短的时间间隔更新位置,或者我应该寻找其他方法(计时器+手动询问位置)?locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigationlocationManager.allowsBackgroundLocationUpdates=truelocationManager.distanceFilter=kCLDistanceFilt

ios - 如何在 swift 中使用 CoreLocation?

我已经尝试在我的Swift应用程序中使用CoreLocation,但没有成功。我有以下非常简单的代码:(我已经链接了CoreLocation库。)importUIKitimportCoreLocation@UIApplicationMainclassAppDelegate:UIResponder,UIApplicationDelegate,CLLocationManagerDelegate{varwindow:UIWindow?varlocationManager:CLLocationManager=CLLocationManager()locationManager.delegate

ios - 背景中的位置不起作用

我正在开发一个代码,它应该每10分钟获取我的位置并在CoreData中保存。当我使用conectavo应用程序进入后台时,xcode看不到该服务正在运行的日志,但是当我出去走在街上时,他根本没有保存或保存次数太少。这是我的代码的一部分,应该执行此功能。请参阅保存在代码数据中:varsaveLocationInterval=60.0funcapplicationDidEnterBackground(application:UIApplication){UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHa

ios - 如何设置自定义距离 Filter ,在 Swift 中是否可行?

我是Swift的新手,我尝试使用这个HowtosetaccuracyanddistancefilterwhenusingMKMapView不知道为什么这段代码不起作用://startmehtodoutofscopelazyvarlocationManager:CLLocationManager!={letlocationManager=CLLocationManager()//configerationforuserlocationaccess//Thedelegateobjecttoreceiveupdateevents.locationManager.delegate=self//

ios - Swift:利用 CLLocationManagerDelegate 和 CoreLocation.framework 导致 "Use of undeclared type"错误

我正在播放一个youtube视频,该视频提供了一个基本示例,说明如何利用Xcode的定位服务为程序编写一种map用户界面。我按照设置程序的视频中的步骤进行操作,并在尝试编译应用程序时收到一个假设简单的“使用未声明的类型”错误。https://www.youtube.com/watch?v=qrdIL44T6FQ-链接到youtube视频。问题出现在类创建行。importUIKitimportMapKitimportCoreLocationclassViewController:UIViewController,MKMapViewDelegate,CLLocationManagerDel

ios - 无法下标索引类型为 int 的 [CLPlacemark] 类型的值

我想检索当前位置。我在swiftXcode7上工作。我看了PLUSIEUR教程,但每次他们都使用相同的方法。这是我的代码和我的错误:!Error:Cannotsubscriptavalueoftype[CLPlacemark]withanindextypeintimportUIKitimportCoreLocationclassViewController:UIViewController,CLLocationManagerDelegate{letLocationManager=CLLocationManager()overridefuncviewDidLoad(){super.vie

Swift iOS 谷歌地图,坐标路径

我正在尝试在我的应用程序中创建一个功能,它将引导用户找到我创建的标记。这是我正在使用的代码,效果很好,它获取用户当前位置并将其显示在map上。但是我怎样才能得到一个标记的方向呢?任何awnser都会有帮助classKarta:UIViewController,CLLocationManagerDelegate{@IBOutletvarmapView:GMSMapView!letlocationManager=CLLocationManager()overridefuncviewDidLoad(){super.viewDidLoad()//allowapptotrackuserlocat

ios - 使用 Core Location 的 Swift 后台获取位置更新

我想在我的应用程序上使用后台获取位置更新服务。但是不要在这里显示我的代码的任何输出我需要你的帮助。importCoreLocationclassViewController:UIViewController,UITextFieldDelegate,CLLocationManagerDelegate{varlocationManager:CLLocationManager=CLLocationManager()overridefuncviewDidLoad(){super.viewDidLoad()self.locationManager.delegate=selflocationMan

swift - 如何正确获取用户坐标?

我使MapViewController采用这种方式采用CLLocationManagerDelegate协议(protocol):extensionMapViewController:CLLocationManagerDelegate{funclocationManager(_manager:CLLocationManager,didUpdateLocationslocations:[CLLocation]){letusrLocation:CLLocation=locations[0]asCLLocation//readableprint("lat=\(usrLocation.coor