# Modules.Geofence.Region
Represents a geographic region to be monitored.
# Overview
A Region is a circular area defined by a center point (latitude, longitude) and a radius in meters. Use the Modules.Geofence.createRegion method to create a region.
# Properties
# center
An object representing the center coordinate for the region.
The object must contain the following properties:
latitude
: The latitude of the point to be testedlongitude
: The longitude of the point to be tested
# notifyOnEntry
A boolean that controls whether the region will notify on entry.
If true
, an enterregions event is generated when the device enters the region.
If false
, no event is generated. Default is true
.
This property can only be set when calling createRegion.
# notifyOnExit
A boolean that controlls whether the region will notify on exit.
If true
, an exitregions event is generated when the device exit the region.
If false
, no event is generated. Default is true
.
This property can only be set when calling createRegion.
# Methods
# containsCoordinate
Returns true
if the coordinates passed to the method represent a point that is within the region.
On iOS, if the device is located in a Modules.Geofence.Region that has just started being monitored, an enterregions event is not generated. Instead, when starting to monitor a new region, use this method to check if the device is located within a the current Region.
For example, the following code creates a new Region and then immediately checks if the device is located in the newly created region and, if so, displays a notification.
var region = Geofence.createRegion({
center: {
latitude:37.389601,
longitude:-122.050169
},
radius: 50,
identifier: 'Appcelerator'
});
// Should be true
if (region.containsCoordinate(e.coords)) {
var notification = Ti.App.iOS.scheduleLocalNotification({
alertBody: 'Point is within region: ' + region.identifier
});
}
Parameters
Name | Type | Description |
---|---|---|
point | Dictionary | A Dictionary that defines |
Returns
- Type
- void