Reputation: 827
In one of the requirement, I need to integrate Google Map with Dash framework and on map click - retrieve lat , long and address (on map click event).
I was able to retrieve the same using google API and flask framework using java script which gives Lat ,Long and Address based on map click event and renders Google Map
Here is the python code used in flask framework :
#!/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
Any guidance how to achieve the same using Dash Framework would be really helpful. I can share JS Script Code as well if needed.
Upvotes: 0
Views: 1878
Reputation: 6024
You could use Dash Leaflet for the map visualization. It supports arbitrary tile provides, i.e. also Google, as well as click events. You would need another library for the reverse geocoding though, one options is Googles API.
Disclaimer: I am the maintainer of Dash Leaflet.
Upvotes: 2