-
-
Save pietromalerba/5534795 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; | |
Titanium.Geolocation.distanceFilter = 0; | |
var win = Ti.UI.createWindow({backgroundColor: '#fff'}); | |
var label = Ti.UI.createLabel(); | |
win.add(label); | |
win.open(); | |
function reportPosition(e) { | |
if (!e.success || e.error) { | |
label.text = 'error: ' + JSON.stringify(e.error); | |
} | |
else { | |
var accuracy = e.coords.accuracy; | |
var timestamp = e.coords.timestamp; | |
label.text = 'geo time: ' + new Date(timestamp) + ', accuracy: ' + accuracy; | |
} | |
} | |
// this fires once | |
Titanium.Geolocation.getCurrentPosition(reportPosition); | |
// this fires whenever the distance filter is surpassed | |
Titanium.Geolocation.addEventListener('location', reportPosition); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment