Reputation: 3136
This is my code on Titanium Appcelerator:
function ApplicationWindow(title) {
var self = Ti.UI.createWindow({
title:title,
backgroundColor:'white'
});
var button = Ti.UI.createButton({
height:44,
width:200,
title:L('openWindow'),
top:200
});
self.add(button);
function getPosition() {
alert("In the Function");
Titanium.Geolocation.getCurrentPosition(function(e) {
Titanium.Geolocation.distanceFilter = 10;
Ti.Geolocation.preferredProvider = "gps";
if (e.error) {
Ti.UI.createAlertDialog({
title: L('geolocate_failure'),
message: e.error
}).show();
return;
}
var found = new Object();
locateIndicator.show();
found.longitude = e.coords.longitude;
found.latitude = e.coords.latitude;
found.altitude = e.coords.altitude;
found.heading = e.coords.heading;
found.accuracy = e.coords.accuracy;
found.speed = e.coords.speed;
found.timestamp = e.coords.timestamp;
found.altitudeAccuracy = e.coords.altitudeAccuracy;
return found
});
}
button.addEventListener('click', function() {
alert("button click");
getPosition();
});
return self;
};
module.exports = ApplicationWindow;
When I am Running this code in Android Emulator it is giving a pop up reading "Location is currently unavailable."
Does this mean until I run this code on a mobile(GPS Enabled) It wont give me any GPS Related output ? or it is something with my code ?
Thank you.
Upvotes: 2
Views: 1724
Reputation: 231
If you want to run geo location service in your emulator then you have to set latitude and longitude in ddms.
Upvotes: 2