Modules.Geofence.Region
Represents a geographic region to be monitored.
A Region is a circular area defined by a center point (latitude, longitude) and a radius in meters. Use the Geofence.createRegion method to create a region.
Extends: Titanium.Proxy · Since: 3.1.3 · Platforms: android, iphone, ipad
Properties #
center#
Type: Dictionary
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#
Type: Boolean
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 Geofence.createRegion().
notifyOnExit#
Type: Boolean
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 Geofence.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 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
});
}
| Name | Type | Summary | Optional |
|---|---|---|---|
point | Dictionary | A Dictionary that defines latitude and longitude properties. | No |