Leaflet 是领先的用于移动友好交互式地图的开源 JavaScript 库,它拥有大多数开发者所需要的所有地图功能。
dash_leaflet是leaflet.js的dash模块接口,它的使用说明网站:https://dash-leaflet.herokuapp.com/
各省市的轮廓数据:https://geo.datav.aliyun.com/areas_v2/bound/100000_full.json
制作自己感兴趣的专题图。下面是用das
Leaflet 是领先的用于移动友好交互式地图的开源 JavaScript 库,它拥有大多数开发者所需要的所有地图功能。
dash_leaflet是leaflet.js的dash模块接口,它的使用说明网站:https://dash-leaflet.herokuapp.com/
各省市的轮廓数据:https://geo.datav.aliyun.com/areas_v2/bound/100000_full.json
制作自己感兴趣的专题图。下面是用dash_leaflet制作浙江大学紫金港校区地图的程序
import dash_html_components as html
import dash
import dash_leaflet as dl
from dash.dependencies import Input, Output
attribution = 'https://ditu.amap.com/' #高德地图
map=dl.Map([dl.TileLayer(attribution=attribution),dl.LayerGroup(id="layer")],
center=[30.306, 120.084], #浙江大学紫金港校区经纬度
zoom=16,id="map",style={'width': '100%', 'height': '590px'})
app = dash.Dash()
app.layout = html.Div([map])
@app.callback(Output("layer", "children"), [Input("map", "click_lat_lng")])
def map_click(click_lat_lng):
return [dl.Marker(position=click_lat_lng, children=dl.Tooltip("({:.3f}, {:.3f})".format(*click_lat_lng)))]
if __name__ == '__main__':
app.run_server()
程序显示如下地图,鼠标点击出现蓝色箭头。

答案:
dash_leaflet是leaflet.js的dash模块接口,它的使用说明网站:https://dash-leaflet.herokuapp.com/
各省市的轮廓数据:https://geo.datav.aliyun.com/areas_v2/bound/100000_full.json
制作自己感兴趣的专题图。下面是用dash_leaflet制作浙江大学紫金港校区地图的程序
import dash_html_components as html
import dash
import dash_leaflet as dl
from dash.dependencies import Input, Output
attribution = 'https://ditu.amap.com/' #高德地图
map=dl.Map([dl.TileLayer(attribution=attribution),dl.LayerGroup(id="layer")],
center=[30.306, 120.084], #浙江大学紫金港校区经纬度
zoom=16,id="map",style={'width': '100%', 'height': '590px'})
app = dash.Dash()
app.layout = html.Div([map])
@app.callback(Output("layer", "children"), [Input("map", "click_lat_lng")])
def map_click(click_lat_lng):
return [dl.Marker(position=click_lat_lng, children=dl.Tooltip("({:.3f}, {:.3f})".format(*click_lat_lng)))]
if __name__ == '__main__':
app.run_server()
程序显示如下地图,鼠标点击出现蓝色箭头。

答案: