【问题标题】:Xamarin GeoLocatorPlugin change minDistance during runtimeXamarin GeoLocatorPlugin 在运行时更改 minDistance
【发布时间】:2018-10-12 13:22:10
【问题描述】:

在我的 xamarin 应用程序中,我需要地理围栏。

我正在使用GeoLocatorPlugin

有没有办法在运行时(开始监听后)影响参数“minDistance”?

await StartListeningAsync(TimeSpan.FromSeconds(5), "minDistance");

背景: 我想根据给定的“兴趣点”(它们到用户位置的距离)优化“位置更新(更改)”的间隔。

提前问候和谢谢。

【问题讨论】:

    标签: xamarin location geofencing


    【解决方案1】:

    我目前正在通过网络服务获取时间和距离(我现在不知道你的情况,但你可以做一些与此非常相似的事情),我像这样保存(设备的本地存储):

      dynamic obj = JsonConvert.DeserializeObject<Rootobject>(responseString);
                    Application.Current.Properties["gps_distancia"] = obj.rssUser.gps_distancia;
                    Application.Current.Properties["gps_tempo"] = obj.rssUser.gps_tempo;
    

    然后我调用来自网络服务的存储时间和距离并保存在设备中:

               int tempoWebService = Int32.Parse(Application.Current.Properties["gps_tempo"].ToString()); 
            int distanciaWebService = Int32.Parse(Application.Current.Properties["gps_distancia"].ToString()); 
    
    
            await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(tempoWebService), distanciaWebService, true, new Plugin.Geolocator.Abstractions.ListenerSettings
            {
                ActivityType = Plugin.Geolocator.Abstractions.ActivityType.AutomotiveNavigation,
                AllowBackgroundUpdates = true,
                DeferLocationUpdates = true,
                DeferralDistanceMeters = 1,
                DeferralTime = TimeSpan.FromSeconds(1),
                ListenForSignificantChanges = true,
                PauseLocationUpdatesAutomatically = false
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-10
      • 2016-01-13
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 2011-04-10
      • 2011-01-01
      • 2010-12-05
      相关资源
      最近更新 更多