Geofence
Simple geofencing using Google or other geolocation providers's API
Screenshot
examples/cli.js
node cli.js --apiKey=$apiKey --destination="San Francisco, CA" --mode=driving --updateInterval=1 --fenceDurationValue=25
Installation
Install with npm:
npm install geofence --save
Usage
The current location and destination can be address or lat/long. See Google's Distance Matrix API
let options = {
apiKey: "ENTER YOUR API HERE",
updateInterval: 5,
getCurrentLocation: getCurrentLocation,
insideGeofenceCallBack: insideGeofenceCallBack,
updateDistanceCallBack: updateDistanceCallBack,
loopForever: false,
activateFenceOn: "duration",
fenceDurationValue: 25 * 60,
fenceDistanceValue: 1000,
};
let locationSepc = {
destination: "Oakland, CA",
mode: "driving"
};
var geofence = require("geofence")(options, locationSepc);
geofence.start(options);
Examples
- examples/example.js: Simple example
- examples/cli.js: demonstrates running with command line arguments:
node cli.js --apiKey=YOUR_API_KEY --destination="San Francisco, CA"
- examples/termux.js: demonstrates running inside Termux and Termux-API on Android using device GPS and system notifications. Run with:
node termux.js --apiKey=YOUR_API_KEY --destination="320 Main St, Venice, CA" --fenceDurationValue=300 --updateInterval=10
- examples/termux_prompt.js: demonstrates running inside Termux and Termux-API on Android using device GPS and system notifications. It receives the inputs from command prompt:
node termux_prompt.js