0

これが私のグループのプロジェクトです:https ://github.com/stuycs-ml7-projects/YAN-SHAN-PHAN-WU

GPSを使用して場所にメッセージを保存できるアプリ(ウェブサイト)に取り組んでいます。メッセージは、特定の座標でのみアクセスおよび保存できます。

私が持っているものを見ていきます。

HTMLは変数を初期化します

<input type="hidden" id="Latitude" name="Latitude">
<input type="hidden" id="Longitude" name="Longitude">

document.ready関数を使用してgetLocation()を呼び出し、非表示フィールドに格納します。

function getLocation()
  {if (navigator.geolocation)
    {    navigator.geolocation.watchPosition(showPosition);     }
  }
function showPosition(position)
  {
      document.getElementById("Latitude")  =  position.coords.latitude;
      document.getElementById("Longitude") =  position.coords.longitude;
  }

$(document).ready(function() {
   getLocation();
});

ボタンを押すと、app.pyのデータが要求されます

Latitude = request.form['Latitude']
Longitude = request.form['Longitude']

次に、その場所ですべてのメッセージを見つけます

messages = database.returnMessagesinRange(Latitude,Longitude)
            return render_template('SCAN.html',messages=messages,
                Latitude =   Latitude, Longitude = Longitude)

線のどこかで、座標が失われ、変数が空白になってしまいます。修正方法のアイデア、またはすべてのトラブルを回避するためのショートカットはありますか?

4

1 に答える 1

1

これは簡単な推測ですが、document.getElementById("Latitude") = ... を document.getElementById("Latitude").value = ... に置き換えてみてください。

于 2013-01-13T05:36:26.290 に答える