plotly画地图
需要去mapbox官网注册一个token
import plotly.express as px
import plotly.graph_objects as go
def one_car_plot(x, y, car: Car):
"""
一辆车停放位置
参考链接: https://zhuanlan.zhihu.com/p/87163211
"""
hovertext = str(car)
fig = go.Figure(go.Scattermapbox(mode='markers',
lon=[x],
lat=[y],
hovertext=hovertext,
hoverinfo='text',
marker = dict(color='yellow', size=12),
title=f'{car.name}-位置'
))
fig.update_layout(mapbox = {'accesstoken': PLOTLY_TOKEN,
# 'style':'satellite',
'center': {'lon': CEN_LON, 'lat': CEN_LAT},
'zoom': 10,
},
margin = {'l': 0, 'r': 0, 't': 0, 'b': 0})
return fig