Here is my group’s project: https://github.com/stuycs-ml7-projects/YAN-SHAN-PHAN-WU
We’re working on app (a website) that can store messages at locations using GPS. Messages can only be accessed and stored at their specific coordinates.
I’ll go through what I have.
HTML initializes the variables
<input type="hidden" id="Latitude" name="Latitude">
<input type="hidden" id="Longitude" name="Longitude">
I use a document.ready function to call getLocation() which stores them in the hidden fields.
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();
});
If I press a button, it will request the data in app.py
Latitude = request.form['Latitude']
Longitude = request.form['Longitude']
Then find all the messages at the location
messages = database.returnMessagesinRange(Latitude,Longitude)
return render_template('SCAN.html',messages=messages,
Latitude = Latitude, Longitude = Longitude)
Somewhere along the line, I lose the coordinates and end up with blank variables. Any ideas how to fix, or possibly a shortcut to avoid all the trouble?
That’s a quick guess, but try replacing document.getElementById(“Latitude”) = … with document.getElementById(“Latitude”).value = …