# Modules.Geofence.Region

Represents a geographic region to be monitored.

Availability
3.1.3
3.1.3

# 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

Availability
3.1.3
3.1.3
center :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 tested
  • longitude: The longitude of the point to be tested

# identifier

Availability
3.1.3
3.1.3
identifier :String

The unique identifier of the region.


# notifyOnEntry

Availability
3.1.3
3.1.3
notifyOnEntry :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 createRegion.


# notifyOnExit

Availability
3.1.3
3.1.3
notifyOnExit :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 createRegion.


# radius

Availability
3.1.3
3.1.3
radius :Number

The radius of the region to monitor in meters.

# Methods

# containsCoordinate

Availability
3.1.3
containsCoordinate(point) void

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 latitude and longitude properties.

Returns

Type
void