0
我想開發一個移動應用程序,它基本上會幫助您根據來自他們的地理位置信息來跟蹤您的朋友和家人的位置。所以我明白,這將涉及獲得他們的許可,在訪問數據之前。鈦應用程序開發:從智能手機接收地理位置
我對在Titnaium Appcelerator中開發應用程序有基本的瞭解。但是我需要幫助確定如何與第三方設備通信,請求許可並檢索其地理位置。
我發展將非常類似於這樣的應用程序:http://goo.gl/dvCgP
我想開發一個移動應用程序,它基本上會幫助您根據來自他們的地理位置信息來跟蹤您的朋友和家人的位置。所以我明白,這將涉及獲得他們的許可,在訪問數據之前。鈦應用程序開發:從智能手機接收地理位置
我對在Titnaium Appcelerator中開發應用程序有基本的瞭解。但是我需要幫助確定如何與第三方設備通信,請求許可並檢索其地理位置。
我發展將非常類似於這樣的應用程序:http://goo.gl/dvCgP
你可以做到這一點的唯一方法是通過建立一箇中央網絡服務,手機本身不能互相蒐集GPS位置,而不管那麼,您無法將所有其他手機信息存儲在您自己的設備上。
設置一個網絡服務,當手機發布它們時將保存GPS位置,然後讓該服務返回他們連接的其他手機。一旦你建立了這個服務,在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.');
}
});
});
我認爲不需要任何權限。我們使用鈦時允許位置信息。如果出現錯誤,您可以手動將權限添加到tiapp.xml,如ACCESS_NETWORK_STATE,ACCESS_MOCK_LOCATION,ACCESS_FINE_LOCATION –