动态在地图上进行更改

时间:2018-07-11 08:20:53

标签: python html flask maps folium

我正在编写一个应用程序,其中使用了folium作为地图api。现在,我可以创建一个具有给定数据集的地图,该数据集由一些多头和纬度组成。我还想添加的是通过时间变量在不同的位置弹出不同的弹出窗口。

例如,有10个标记,我希望它们在5秒的时间范围内以3、4、2、1的顺序显示。

我曾经考虑过用javascript实现它,但是folium创建了,并且单独将文件另存为html,因此我无法添加js代码。 任何帮助表示赞赏!

这是主要方法,

if __name__ == '__main__':

# Check whether the number of file that should be displayed passed over the command line
if argv.__len__() == 2:
    try:
        if int(argv[1]) > 0:
            number_of_files_tbr = int(argv[1])
        else:
            print("Enter a number greater than zero!")
            exit()
    except Exception:
        print("Give a numerical value!")
        exit()
else:
    number_of_files_tbr = 2 # tbr = to be read

trajectory_path = './data/'
trajectory_datas = []
colors_for_icons = ['red', 'blue', 'green', 'purple', 'darkred', 'beige', 'darkblue', 'gray']

# Get all the files with extension '.csv' and put them into an array with the folder name
data_paths = [join(trajectory_path, path) for path in listdir(trajectory_path) if isfile(join(trajectory_path, path)) and ('.csv' in path) ]

# Extract the data from the trajectory files with the given number of files
for x in range(number_of_files_tbr):
    trajectory_datas.append(read_csv_data(data_paths[x]))

# Create the map with a sample coord
area = create_map(trajectory_datas[0][0])

for tr in trajectory_datas:
    color_of_icon = choice(colors_for_icons)
    for data_point in tr:
        put_marker(data_point, area, color_of_icon)

area.save(str(Path.home()) + "/Desktop/map.html")

0 个答案:

没有答案