diff --git a/app.py b/app.py index 8ee52bb..5a56afb 100644 --- a/app.py +++ b/app.py @@ -12,7 +12,9 @@ from wtforms import StringField, FileField, SubmitField, DateTimeField, SelectFi from wtforms.validators import DataRequired, Length import requests from config import Config +from geopy.geocoders import Nominatim +geolocator = Nominatim(user_agent="Bachemapa @ baches.qro.mx") def create_app(config=Config): app = Flask(__name__) app.config.from_object(config) @@ -91,8 +93,10 @@ def create_app(config=Config): 'lng': request.form['lng'], 'typeofpin': request.form['typeofpin'], 'added_by': current_user.id, - 'description': request.form['description'] + 'description': request.form['description'], + 'address': str(geolocator.reverse(str(request.form['lat'])+ ", "+request.form['lng'])) } + print(geolocator.reverse(str(request.form['lat'])+ ", "+request.form['lng'])) mongo.db.pins.insert_one(pin) flash('¡Gracias por tu aportación!') return redirect(url_for('index')) diff --git a/templates/index.html b/templates/index.html index fc9757e..6a86e4a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -38,7 +38,7 @@ iconSize:[10,10], iconAnchor:[5,5], }); - markerCluster.addLayer(L.marker([{{ pin.lat }}, {{ pin.lng }}], {icon: icon}).bindPopup("{{ pin.description }}
Fecha del reporte: {{pin.time}}
Fecha del reporte: {{pin.time}}