Titanium - Posición GPS
Como obtener tu posición:
Ti.Geolocation.preferredProvider = "gps";
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;
//
// GET CURRENT POSITION - THIS FIRES ONCE
//
var longitude, latitude;
Titanium.Geolocation.getCurrentPosition(function(e) {
if(!e.success || e.error) {
Ti.API.info('error:' + JSON.stringify(e.error));
return;
}
longitude = e.coords.longitude;
latitude = e.coords.latitude;
var altitude = e.coords.altitude;
var heading = e.coords.heading;
var accuracy = e.coords.accuracy;
var speed = e.coords.speed;
var timestamp = e.coords.timestamp;
var altitudeAccuracy = e.coords.altitudeAccuracy;
Titanium.API.info('geo - current location: ' + new Date(timestamp) + ' long ' + longitude + ' lat ' + latitude + ' accuracy ' + accuracy);
});
Comentarios
Publicar un comentario