0

私は基本的に、友人や家族からの位置情報に基づいて友人や家族の位置を追跡するのに役立つモバイルアプリを開発しようとしています. したがって、これには、データにアクセスする前に、彼らの許可を得る必要があることを理解しています.

私は、Titnaium Appcelerator でアプリを開発する基本的な知識を持っています。しかし、サードパーティのデバイスと通信し、許可を求め、地理位置情報を取得する方法を理解するのに助けが必要です.

私が開発しているアプリはこれに非常に似ています: http://goo.gl/dvCgP

4

1 に答える 1

1

これを行う唯一の方法は、中央の 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.');
        }
    });

});
于 2012-09-09T17:27:21.397 に答える