I need entry and exit notification in my app. so I have written below code for the same and it is working as expected. but i want to check for multiple overlay or region.
for an example i have set of 3 overlay or region with specific coordinates. i want to check entry and exit for the region near by user's current location .
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");
}
You should maybe make use of CLLocationManager
's region monitoring and set up geofencing regions.
Create a list of CLCircularRegion
or other CLRegion
type.
Add all the regions by calling locationManager.StartMonitoring(yourRegion)
for each region.
When you are done with a specific region remove it by calling locationManager.StopMonitoring(yourRegion)
Then when a region is entered or left the RegionLeft(CLLocationManager manager, CLRegion region)
or RegionEntered(CLLocationManager manager, CLRegion region)
delegate methods will be called. You will need to override these methods in a CLLocationManagerDelegate
class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.