使用TimeStampedGeojson Folium插件未在地图上显示的点

时间:2019-11-04 07:52:46

标签: folium

我跟随https://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Plugins.ipynb使用TimeStampedGeojson folium插件创建了自己的地图,“时间”滑块正常工作,但点未显示在地图上。我使用的是浦那城市坐标,其目的是在一个月内显示带有变化的图标的多点坐标以及具有时间滑块功能的弹出窗口。

points = [
{
    'time': '2019-09-01',
    'popup': '<h1>address1</h1>',
    'coordinates': [18.528387, 73.874251]
},
{
    'time': '2019-09-02',
    'popup': '<h1>address1</h1>',
    'coordinates': [18.456863, 73.801601]
},
{
    'time': '2019-09-03',
    'popup':'<h1>address1</h1>',
    'coordinates': [18.527615, 73.872384]
},
{
    'time': '2019-09-04',
    'popup': '<h1>address1</h1>',
    'coordinates': [18.528387, 73.874251]},
{
    'time': '2019-09-05',
    'popup': '<h1>address1</h1>',
    'coordinates': [18.456863, 73.801601]}]
features = [
{
    'type': 'Feature',
    'geometry': {
        'type': 'Point',
        'coordinates': point['coordinates'],
    },
    'properties': {
        'time': point['time'],
        'popup': point['popup']
    }
} for point in points]

features.append(
{
    'type': 'Feature',
    'geometry': {
        'type': 'LineString',
        'coordinates':[
            [18.528387, 73.874251],
            [18.456863, 73.801601],
            [18.527615, 73.872384],
            [18.528387, 73.874251],
            [18.456863, 73.801601]
        ] ,
    },
    'properties': {
        'popup': 'Current address',
        'times': [
            '2019-09-01',
            '2019-09-02',
            '2019-09-03',
            '2019-09-04',
            '2019-09-05'
        ]
    }
})
m = folium.Map(
location=[18.5204,73.8567],
tiles='cartodbpositron',
zoom_start=10,)

plugins.TimestampedGeoJson(
{
    'type': 'FeatureCollection',
    'features': features
},
auto_play=False,
loop=False,
#max_speed=1,
loop_button=True,
date_options='YYYY/MM/DD',
#time_slider_drag_update=True,
duration='P2D').add_to(m)

This is the output of code in jupyter

1 个答案:

答案 0 :(得分:0)

位置将在地图上呈现,请尝试缩小地图的当前视图。我怀疑问题出在坐标变量内的纬度/经度位置顺序不正确。