forked from orson/bachemap
reverse geocoding a la hora de guardar en la DB
This commit is contained in:
parent
115743b6f3
commit
b118d71366
6
app.py
6
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'))
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
iconSize:[10,10],
|
||||
iconAnchor:[5,5],
|
||||
});
|
||||
markerCluster.addLayer(L.marker([{{ pin.lat }}, {{ pin.lng }}], {icon: icon}).bindPopup("<b>{{ pin.description }}</b><p>Fecha del reporte: {{pin.time}}</p><br><img src='{{ pin.photo }}'>"));
|
||||
markerCluster.addLayer(L.marker([{{ pin.lat }}, {{ pin.lng }}], {icon: icon}).bindPopup("<b>{{ pin.description }}</b>{% if pin.address %}<br>{{pin.address}}{% endif %}<p>Fecha del reporte: {{pin.time}}</p><br><img src='{{ pin.photo }}'>"));
|
||||
|
||||
//markerCluster.addlayer(
|
||||
//L.marker([{{ pin.lat }}, {{ pin.lng }}], {icon: icon}).addTo(map)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user