我现在想知道" favicon.ico"来自。这真的很奇怪。
我使用geopy将位置地理编码为纬度和经度,然后我使用这些值在Google地图上创建标记(Flask GoogleMaps)。
这是一段代码:
try:
print findroomcity
location = geolocator.geocode(findroomcity)
print location, location.latitude, location.longitude
if location:
mymap = Map(
identifier="view-side",
lat=location.latitude,
lng=location.longitude,
markers=[(location.latitude, location.longitude)],
zoom = 12
)
else:
print "location is none"
在这种情况下,findroomcity
是" dortmund"。它实际上是从表格中抓取的。
如果我提交表单,则实际创建了地图,因此它不使用else block
但是它告诉我在NoneType中的位置并且没有属性纬度。似乎它调用try块三次,第一次findroomcity
是" favicon.ico",也是最后一次
我甚至不使用" favicon.ico"在我的整个项目中,我知道它必须在某个地方,但我检查了每个.py文件,并搜索了每个print
。我真的非常困惑,我一直在寻找,但也许有人遇到过类似的东西。
以下是创建地图的整个方法:
# Die Filter Funktion mit Google Maps
@app.route('/<findroomcity>', methods=["GET", "POST"])
def find_room(findroomcity):
form = FilterZimmerForm()
if form.validate_on_submit():
query = Zimmer.query
filter_list = ["haustiere_erlaubt","bettwaesche_wird_gestellt","grill_vorhanden","safe_vorhanden","kuehlschrank_vorhanden","rauchen_erlaubt","parkplatz_vorhanden",
"kochmoeglichkeit_vorhanden","restaurant_im_haus_vorhanden","handtuecher_werden_gestellt","tv_vorhanden","waschmoeglichkeit_vorhanden","wlan_vorhanden"]
for filter_name in filter_list:
if getattr(form, filter_name).data:
query = query.filter(getattr(Zimmer, filter_name).is_(True))
all_rooms_in_city = query.all()
else:
all_rooms_in_city = Zimmer.query.order_by(desc("stadt")).all()
try:
print findroomcity
location = geolocator.geocode(findroomcity)
print location, location.latitude, location.longitude
if location:
mymap = Map(
identifier="view-side",
lat=location.latitude,
lng=location.longitude,
markers=[(location.latitude, location.longitude)],
zoom = 12
)
else:
print "location is none"
except AttributeError as e:
flash("Ort nicht gefunden")
print e
return redirect(url_for('index'))
except GeocoderTimedOut as e:
print e
sleep(1)
return render_template('zimmer_gefunden.html', mymap=mymap, all_rooms_in_city=all_rooms_in_city, findroomcity=findroomcity, form=form)
修改
我真的不知道它来自哪里,我现在使用:
if location.latitude is not None: