Hi, i'm developping a mobile app using titanium SDK version 3.2.3.GA. In my App i need to enable the gps to know the current position for user. When running, all works fine, i get the user's coords (latitude and longitude)but only if i set a manual Location with DDMS as the Tracking Position on the documentation GPS Doc. i'm beeginner and may be my question is stupid but I wan't to get the current position of users automaticlly when the gps is enabled. Any idea to do this ? Any help please. Thanks. This is my code :
Ti.Geolocation.Android.manualMode = true; var gpsProvider = Ti.Geolocation.Android.createLocationProvider({ name: Ti.Geolocation.PROVIDER_GPS, minUpdateTime: 0, minUpdateDistance: 0 }); Ti.Geolocation.Android.addLocationProvider(gpsProvider); Titanium.API.info('1'); Titanium.Geolocation.addEventListener('location', function(e) { Titanium.API.info('12'); if (e.success && !e.error) { Titanium.API.info('123'); var longitude = e.coords.longitude; var 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('1234'); Titanium.API.info('geo - current location: ' + new Date(timestamp) + ' long ' + longitude + ' lat ' + latitude + ' accuracy ' + accuracy); } Titanium.API.info('12345'); });