我想将一个标记移到另一个

时间:2019-01-05 14:30:28

标签: javascript python leaflet folium

因此,我在Python中使用了Python(Folium)库来获取地图和标记。如何移动标记?我附上了一张图片。如果您还有其他方法可以解决,那么我也可以为我提供帮助。 enter image description here

使用(Folium)创建的地图。我搜索了不同的库,但没有任何效果。我的问题完全基于地理位置跟踪。

2 个答案:

答案 0 :(得分:0)

如果您希望能够拖动标记:目前尚无法使用大叶草。虽然很容易将其添加到由folium生成的html中。找到定义标记的部分,然后添加dragable: true,如下所示:

var foo = L.marker(
    [0, 0],
    {
        icon: new L.Icon.Default(),
        draggable: true,
        }
    ).addTo(bar);

如果您要制作动画,则可以考虑使用TimestampedGeoJson插件,尽管可能需要花费一些精力才能使其运行:

https://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Plugins.ipynb#Timestamped-GeoJSON

答案 1 :(得分:0)

df = pd.read_excel("file.xlsx")
IconUrl = "https://cdn.icon-icons.com/icons2/1465/PNG/128/604bullettrain_100995.png"

m = folium.Map([-3.049648, 53.4372116], zoom_start = 10)



# step 1
TempFeature = []
# do the following command for each marker 
temp_df = df.query(f"Marker_id == {1}")

TempFeature.append({ 'type': 'Feature',

                 'geometry': { 'type': 'LineString',

#                               example coordinates 
#                               [
#                                (-3.049648, 53.4372116),
#                                (-3.04967139134615, 53.4372056616587),
#                                (-3.04972986971154, 53.4371908158053),
#                                 .
#                                 .
#                                 .
#                                (-3.04972986971154, 53.4371908158053),
#                               ] 
                              'coordinates': list(zip(temp_df['Longitude'],temp_df['Latitude']))
                             },




                     'properties':{ 
                                     'icon': 'marker',
                                    'iconstyle': {'iconUrl': IconUrl, 'iconSize': [20, 20], },

                                     # time must be like the following format : '2018-12-01T05:53:00'
                                     'times': temp_df['Timetable'] ,
                                     'popup': #html
                      }})



# step 2
TimestampedGeoJson({
                        'type': 'FeatureCollection',
                        'features': TempFeature,
                        }
                        , period='P1D' 
                      ).add_to(m)

m
相关问题