【问题标题】:Google Map Integration with Dash python web framework谷歌地图与 Dash python web 框架的集成
【发布时间】:2020-04-22 10:14:45
【问题描述】:

在其中一项要求中,我需要将 Google Map 与 Dash 框架集成,并在地图上单击 - 检索 lat 、 long 和地址(在地图单击事件上)。

我能够使用 google API 和使用 java 脚本的烧瓶框架检索相同的内容,该脚本根据地图点击事件提供 Lat、Long 和 Address 并呈现 Google Map

这是flask框架中使用的python代码:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/map', methods=['GET', 'POST'])
def map():
location = {}
if request.method == "POST":
    location = request.get_json()
    # latitude = location['latitude']
    # longitude = location['longitude']
    print(location);
return render_template('map.html')

if __name__ == '__main__':
app.run(debug = True) # run app

任何关于如何使用 Dash 框架实现相同目标的指导都会非常有帮助。如果需要,我也可以分享 JS 脚本代码。

【问题讨论】:

    标签: python flask plotly-dash


    【解决方案1】:

    您可以使用Dash Leaflet 进行地图可视化。它支持任意 tile 提供,即 Google 以及 click events。不过,您需要另一个库来进行反向地理编码,其中一个选项是 Googles API。

    免责声明:我是 Dash Leaflet 的维护者。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多