sql >> データベース >  >> RDS >> Mysql

php/mysqlを使用してGoogleマップにポリラインを動的に描画する

    あなたは正しい方向に進んでいるようです。

    phpスクリプトはタイムスタンプパラメータを受け入れ、そのタイムスタンプの後に新しいポイントがデータベースに挿入されているかどうかを確認する必要があります。はいの場合、最新のエントリ(または、車両の移動中にライブトレイルを表示する場合は、そのタイムスタンプ以降のエントリのリスト)を含む応答を返す必要があります。

    クライアント側では、通常またはロングポーリング 、最後の更新のタイムスタンプパラメータを使用します。

    AJAXリクエストがサーバーから新しい情報を受信したら、マーカーをマップ上で移動するだけです。次に、更新されたタイムスタンプパラメータを使用して新しいAJAXリクエストを開始します。

    jQuery を使用した擬似コード風の例 :

    var lastUpdate = '2000/01/01 00:00:00';
    
    function autoUpdate () {
        $.ajax({
           type: "GET",
           url: "phpsqlajax_genxml.php?last_update=" + lastUpdate,
           dataType: 'xml',
           success: function(xmlData) {
    
              // 1. Check if the xmlData is empty. If not we received 
              //    some fresh data.
              // 2. Update lastUpdate from the xmlData with the timestamp from 
              //    the server. Don't use JavaScript to update the timestamp, 
              //    because the time on the client and on the server will 
              //    never be exactly in sync.
              // 3. Move the markers on Google Map.
    
              // Relaunch the autoUpdate() function in 5 seconds.
              setTimeout(autoUpdate, 5000);
           }
        });
    }
    



    1. 日付間隔で複数の列をグループ化して取得

    2. isset($ _ POST ['submit'])は現在機能していません

    3. 自己参加で更新

    4. SQL ANY&ALL演算子