繁体   English   中英

xamarin ios的多个区域的地理围栏

[英]geofencing for multiple region for xamarin ios

我需要在我的应用中输入和退出通知。 所以我写下了相同的代码,它按预期工作。 但我想检查多个叠加或区域。

例如,我有3个叠加或具有特定坐标的区域。 我想检查用户当前位置附近区域的进入和退出。

            if (pointregion.ContainsCoordinate(location.Coordinate) && Entryregion == false)
            {
                Entryregion = true; Exitregion = false;
                ShowNotification("You are just in " + pointregionname + " region", "Alert");
            }
            if (!pointregion.ContainsCoordinate(location.Coordinate) && Entryregion == true)
            {
                Entryregion = false; Exitregion = true;
                ShowNotification("You are just left " + pointregionname + " region", "Alert");
            }

您应该使用CLLocation​Manager的区域监控并设置地理围栏区域。

  1. 创建CLCircularRegion或其他CLRegion类型的列表。

  2. 通过为每个区域调用locationManager.StartMonitoring(yourRegion)来添加所有区域。

  3. 完成特定区域后,通过调用locationManager.StopMonitoring(yourRegion)将其删除

然后,当一个区域进入或离开RegionLeft(CLLocationManager manager, CLRegion region)RegionEntered(CLLocationManager manager, CLRegion region)将调用委托方法。 您需要在CLLocationManagerDelegate类中重写这些方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM