Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created November 1, 2012 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/3993672 to your computer and use it in GitHub Desktop.
Save aaronksaunders/3993672 to your computer and use it in GitHub Desktop.
Quick Example a basic IOS Module for Appcelerator Titanium to demonstrate geofencing
var ci_geofencing = require('ci.geofencing');
Ti.API.info("module is => " + ci_geofencing);
var regions = []
regions.push({
"title" : "Willis Tower",
"latitude" : 41.878844,
"longitude" : -87.635942,
"radius" : 100
});
regions.push({
"title" : "Lincoln Park Zoo",
"latitude" : 41.92007,
"longitude" : -87.63251,
"radius" : 500
});
regions.push({
"title" : "Chicago Theater",
"latitude" : 41.88535,
"longitude" : -87.62745,
"radius" : 200
});
//
// when firing an event you will get information like this
// {
// "source": {
// "id": "ci.geofencing"
// },
// "identifier": "Willis Tower",
// "type": "exited_region" | "entered_region" | "monitoring_region"
// }
//
ci_geofencing.startGeoFencing(regions, function(event) {
Ti.API.info('info ' + JSON.stringify(event, null, 2));
if ( event.type === "exited_region") {
ci_geofencing.stopGeoFencing();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment