<p>我正在尝试使用flask sqlite通过GoogleMaps api呈现数据</p>
<p>当前在my views.py文件中,我有以下方法:</p>
<pre><code>@app.route('/googlemap.html', methods=['POST'])
def map():
if request.method == 'POST':
conn = sqlite3.connect(database.db)
cur = conn.cursor()
c_lat = cur.execute("SELECT latitude FROM table")
c_long = cur.execute("SELECT longitude FROM table")
return render_template(content=render_template('googlemap.html', lat=c_lat.fetchall(), long=c_long.fetchall()))
</code></pre>
<p>在GoogleMapsAPI示例中,他们手动添加每个点</p>
<pre><code>function getPoints() {
return [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586)
];
</code></pre>
<p>但是我想查询每个数据,并将数据库中的每个纬度和经度添加到我的googlemap.html文件中</p>
<pre><code><script>
function getPoints() {
var points = [];
//Add each latitude into points array and return and array off all points
return points
}
</script>
</code></pre>
<p>但是我不知道如何将views.py文件中的<em>lat</em>和<em>long</em>变量添加到代码的javascript部分</p>