如何获得精确度小于1米的Google地图的当前位置,Swift 4



我正在从事施工项目,为此,我想获得确切的当前位置,这必须满足1米的准确性。我正在使用SDK" CllocationManager"使用Google Maps,并且正在获取当前位置,但位置不确定,它在位置上有一些(/-)5米到(/-)10米的位置错误。我想要确切/准确的当前位置,该位置不应超过一英尺的位置精度错误。请帮助我获取确切的当前位置。另外,是否有任何第三方库,任何硬件设备(我可以连接到iOS设备)或其他任何东西,请告诉我。您的宝贵评论将非常感谢。

编辑: -

在这里,我正在共享我的代码以使用cllocationmanager获取当前位置:

override func viewDidLoad() 
{
     super.viewDidLoad()
     self.locationManager = CLLocationManager() 
     self.locationManager.delegate = self 
     self.locationManager.desiredAccuracy = kCLLocationAccuracyBest 
     self.locationManager.requestWhenInUseAuthorization()
     self.locationManager.requestAlwaysAuthorization()
     self.locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{            
     let position = CLLocationCoordinate2D(latitude: manager.location!.coordinate.latitude, longitude: manager.location!.coordinate.longitude)
     marker.position = position 
     print("position:",position)
}

谢谢..

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
   guard let location = manager.location else{
        return
    }
   var currentLocationCoordinate = location.coordinate
}

使用此委托功能,您将获得当前位置

如果要获得确切的位置,则可以在设备的帮助下使用外部GP,您将始终获得此波动。您也可以将位置精度设置为最佳。

https://developer.apple.com/library/content/documentation/performance/conceptual/energyguide-ios/locationbestpractices.html

您应始终在GPS上继电器以确保位置。您可以设置LocationManager.desireaccuracy = kcllocationAccuracybest。它会将您的位置管理器didupdateLocation带有位置数组,每个位置具有其精度,您可以在此处应用逻辑。

请警报以使用Desire精度位置来调用LocationManager.stopupdatingLocation()。

例如

let horizontalAccuracy: Double = 20.0
let howRecent = location.timestamp.timeIntervalSinceNow
    guard CLLocationCoordinate2DIsValid(location.coordinate),
      location.horizontalAccuracy > 0,
      location.horizontalAccuracy < horizontalAccuracy,
      abs(howRecent) < 10 else { return false }
    return true
  }

最新更新