【问题标题】:Xamarin, Android: Why am I getting wrong coordinates?Xamarin,Android:为什么我得到错误的坐标?
【发布时间】:2017-05-21 14:49:50
【问题描述】:

所以我遇到了这个问题 - 下面的代码是我的应用程序中的一个类的一部分。 现在,这门课给了我关于我所在位置的坐标。总是离我真正应该去的地方只有几百米。为什么会这样?这可能是因为我不要求“精细”的准确性吗?

谢谢:)

public void OnLocationChanged(位置位置) {

    _currentLocation = location;
    {         
        // this is needed for my mocked location
        GlobalElapsedRealTime = _currentLocation.ElapsedRealtimeNanos;

        GlobalLatitude = _currentLocation.Latitude;
        GlobalLongitude = _currentLocation.Longitude;

       // Log.Debug("2", "Your Real Location is at " + GlobalLongitude + " // " + GlobalLatitude);

    }
}

public void InitializeLocationManager()
{
    _locationManager = ctxt.GetSystemService(Context.LocationService) as LocationManager;

    if (_locationManager.AllProviders.Contains(LocationManager.NetworkProvider)
       && _locationManager.IsProviderEnabled(LocationManager.NetworkProvider))
    {
        _locationProvider = LocationManager.NetworkProvider;
        Log.Debug("1", "Location Manager has been initialized!");
    }
    else
    {
        _locationProvider = String.Empty;
    }
}

public void StartLocationUpdates()
{
    _locationManager.RequestLocationUpdates(_locationProvider, 0, 0, this);


}

【问题讨论】:

  • 您是否检查过您设备上的另一个 GPS 应用程序是否有同样的问题?
  • 确定我做到了。它没有问题。此外,它总是让我错位到同一个“错误”的地方......?

标签: android xamarin gps


【解决方案1】:

这是因为您使用的是LocationManager.NetworkProvider。这会根据手机信号塔和已知的 WiFi 热点猜测您的位置,并不是特别准确。几百米外听起来是对的。可能有助于确定您在哪个城市或郊区,但不适用于更准确的跟踪。

尝试使用LocationManager.GPSProvider 并确保启用ACCESS_FINE_LOCATION 权限。修复可能需要更长的时间,但它会更准确。准确度取决于它运行的设备(手机 GPS 可能非常好,但并不完全准确,因为芯片通常是根据价格选择的),以及您可以获得多少修复 - 例如,高层建筑可能会干扰它。

更多细节:

https://developer.android.com/reference/android/location/LocationManager.html#GPS_PROVIDER

【讨论】:

  • 是的!我怎么能监督!非常感谢你!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-02
  • 1970-01-01
  • 1970-01-01
  • 2016-11-25
相关资源
最近更新 更多