コード例 #1
0
        protected virtual async Task SetupRegions()
        {
            var location = await GeofencingUtil.GetCurrentLocationAsync();

            try
            {
                MvxTrace.TaggedTrace(MvxTraceLevel.Diagnostic, "Geofencing", "Setup regions");

                var response = await AreaService.Instance.LoadAreasByUserLocation(location.Coordinate.Latitude, location.Coordinate.Longitude);

                var geofencingRegions = response.Select(area => GeofencingProvider.CreateRegion(area.Latitude, area.Longitude, area.Radius, area.ID))
                                        .ToList();

                var updateRegion = GeofencingProvider.CreateUpdateRegion(location.Coordinate.Latitude, location.Coordinate.Longitude, _updateRadius);

                GeofencingProvider.SetRegions(geofencingRegions, updateRegion);
            }
            catch (Exception ex)
            {
                MvxTrace.TaggedTrace(MvxTraceLevel.Error, "Geofencing", ex.BuildAllMessagesAndStackTrace());
            }
        }