def generate_map(self): m = folium.Map(location=[45.509484, -73.600519], tiles="Stamen Terrain", zoom_start=10.5) db = DBHelper() max_price = 300 coordinates = db.get_coordinates(max_price=max_price) def hsv2rgb(h, s, v): return tuple(round(i * 255) for i in colorsys.hsv_to_rgb(h, s, v)) def print_exception(): exc_type, exc_obj, tb = sys.exc_info() f = tb.tb_frame lineno = tb.tb_lineno filename = f.f_code.co_filename linecache.checkcache(filename) line = linecache.getline(filename, lineno, f.f_globals) print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format( filename, lineno, line.strip(), exc_obj)) print(str(sys.exc_info())) print(f"points number: {len(coordinates)}") # I can add marker one by one on the map for coordinate in coordinates: amount_n = float((max_price - coordinate['amount']) / max_price) test_color = hsv2rgb(0.8, amount_n, 1 - amount_n) try: folium.Circle( location=[coordinate['lat'], coordinate['lng']], popup= f"${coordinate['amount']} : https://www.airbnb.ca/rooms/{coordinate['room_id']}", radius=10, color='#%02x%02x%02x' % test_color, fill=True # fill_color='crimson' ).add_to(m) except: print(f"color: {test_color}") print_exception() # Save it as html m.save('mymap.html')