python - Flask Google Maps Infobox with multiple marker images leads to wrong information -
i have flask application user can search room in city typing in cityname.
when cityname typed in user redirected result page, use flask google maps show available rooms on map markers.
i have 2 different marker images (for free users , users paid):
mymap.markers['static/img/map-marker-marker-outside-small.png'] = markerlist mymap.markers['static/img/map-marker-marker-outside-pink.png'] = markerlist_bezahlt
i populate markers list, other informations stored, f.e. room , rooms image, plus clickable , redirects on click details page.
here whole method creates map , markers depending on whether user has payed or free (findroomcity cityname searching user has typed in):
location = geolocator.geocode(findroomcity) if location.latitude not none: mymap = map( identifier="view-side", lat=location.latitude, lng=location.longitude, infobox=[], markers=[], zoom = 12 ) else: print "location none" all_users = user.query.order_by(desc('bezahlt')).all() markerlist = [] markerlist_bezahlt = [] room in all_rooms_in_city: if room.stadt == findroomcity.lower(): try: location2 = geolocator.geocode(room.stadt + " " + room.strasse + " " + room.hausnr, timeout=2) user in all_users: if user.id == room.users_id: if user.bezahlt == false: markerlist.append((location2.latitude, location2.longitude)) mymap.infobox.append(r'''<a href='/details/''' + str(room.id) + "'>" + r'''<img class='marker-img' src='../static/userimg/''' + room.hauptbild + "'/>") else: markerlist_bezahlt.append((location2.latitude, location2.longitude)) mymap.infobox.append(r'''<a href='/details/''' + str(room.id) + "'>" + r'''<img class='marker-img' src='../static/userimg/''' + room.hauptbild + "'/>") except geocodertimedout e: print "in der schleife timeout", e except attributeerror e: print "in der schleife attributeerror", e mymap.markers['static/img/map-marker-marker-outside-small.png'] = markerlist mymap.markers['static/img/map-marker-marker-outside-pink.png'] = markerlist_bezahlt
the problem markers have wrong information stored. guess because splitting 2 markers?
here life example heroku: heroku testing
search "dortmund" , check 2 small blue markers (these both "freeuserzimmer") 1 of them shows payed room
this guess— looking @ source code of search page showing markers can see duplicates of var marker_0
, others. presume you're iterating through markerlist
0 index, markerlist_bezahlt
basing marker_x
names off index location, second list overrides data first markers.
Comments
Post a Comment