Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20362] Android: Ti.Geolocation.getCurrentPosition returns altitude=0 and altitudeAccuracy=null

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-10-25T15:24:54.000+0000
Affected Version/sRelease 5.1.2
Fix Version/sRelease 8.3.0
ComponentsAndroid
Labelsandroid, engSchedule
ReporterNiraj Kumar
AssigneeGary Mathews
Created2016-02-04T05:24:30.000+0000
Updated2019-10-25T15:24:54.000+0000

Description

function locationListener(location) {
 Ti.API.info("Current Location: " + JSON.stringify(location.coords));
} 
Titanium.Geolocation.distanceFilter = 1;
Titanium.Geolocation.purpose = 'Get Current Position';
Titanium.Geolocation.addEventListener('location', locationListener);
Output for the above code snippet shows the location as below:
{
    "accuracy": 100,
    "altitude": 0,
    "altitudeAccuracy": null,
    "heading": 0,
    "latitude": 25.1166228,
    "longitude": 55.390551,
    "speed": 0,
    "timestamp": 1454550108161
}
If we need the altitude value, should we add some extra parameters with it or at what conditions it can provide some value for altitude?

Comments

  1. Jebun Naher 2016-02-04

    Hello, We tested this issue and observed the same output for altitude and altitudeAcccuracy. *Testing Environment:* Appcelerator Studio, build: 4.4.0.201511241829 Appcelerator Command-Line Interface, version 5.1.0 Titanium Command-Line Interface, CLI version 5.0.5, Titanium SDK version : 5.1.2 GA Mac OS X : 10.11.1 (EI Capitan) Device: walton primo v2(android 4.2.2) *Test Output:*
       [INFO] :   geolocation result{"timestamp":1454576798588,"speed":0,"altitude":0,"longitude":90.3713633,"latitude":23.7920789,"accuracy":705,"heading":0,"altitudeAccuracy":null}
       
    *Test Code:*
       var win = Ti.UI.createWindow({
       backgroundColor : '#fff'
       });
       win.addEventListener('click',function(e){
       	if (Ti.Geolocation.locationServicesEnabled) {
       	    Titanium.Geolocation.purpose = 'Get Current Location';
       	    Titanium.Geolocation.getCurrentPosition(function(e) {
       	        if (e.error) {
       	            Ti.API.error('Error: ' + e.error);
       	        } else {
       	        	Ti.API.info(" geolocation result"+ JSON.stringify(e.coords));	        
       	        }
       	    });
       	} else {
       	    alert('Please enable location services');
       	}
       });
       win.open();
       
    *Steps to test:* 1. Create a classic project. 2. Replace app.js with the above code 3. Run the app 4. Click on the window when the app opens and check the console output Thanks.
  2. Chee Kiat Ng 2016-02-10

    [~jnaher] can you test it on other devices as well?
  3. Niraj Kumar 2016-02-10

    Hi, I have tested it on Samsung S5 (Android L 5.0) and Spice Uno(Android M 6.0.1) and got the same response.
  4. Gary Mathews 2019-10-10

    master: https://github.com/appcelerator/titanium_mobile/pull/11275
  5. Sohail Saddique 2019-10-16

    FR: Passed. PR merged.
  6. Samir Mohammed 2019-10-25

    Closing ticket, fix verified in SDK version 8.3.0.v20191023125529. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11275

JSON Source