Created
November 1, 2012 13:37
-
-
Save aaronksaunders/3993672 to your computer and use it in GitHub Desktop.
Quick Example a basic IOS Module for Appcelerator Titanium to demonstrate geofencing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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