これを行う唯一の方法は、中央の Web サービスをセットアップすることです。電話自体は互いに GPS 位置情報を収集できません。それにもかかわらず、他のすべての電話情報を自分のデバイスに保存することはできません。
電話が GPS 位置情報を送信したときに GPS 位置情報を保存する Web サービスをセットアップし、そのサービスが接続されている他の電話にも返すようにします。そのサービスをセットアップしたら、Titanium でそれを使用するのは簡単です。
// First lets get our position
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;
Titanium.Geolocation.getCurrentPosition(function(e) {
if (e.error) {
alert('Cannot get your current location');
return;
}
var longitude = e.coords.longitude;
var latitude = e.coords.latitude;
// We need to send an object to the web service verifying who we are and holding our GPS location, construct that here
var senObj = {userid : 'my_user_id', latitude : latitude, longitude : longitude};
// Now construct the client, and send the object to update where we are on the web server
var client = Ti.Network.createHTTPClient({
onload : function(e) {
// Parse the response text from the webservice
// This response should have the information of the other users youre connected too
var rsp = JSON.parse(this.responseText);
// do something with the response from the server
var user = rsp.otherUsers[0];
alert('Tracking other user named '+user.userid+' at coordinates ('+user.longitude+','+user.latitude+')');
},
onerror : function(e) {
Ti.API.info('[ERROR] communicating with webservice.');
}
});
});