plugins
¶
Folium插件¶
包装一些最流行的 Leaflet 外部插件。
- class folium.plugins.AntPath(locations, popup=None, tooltip=None, **kwargs)¶
基类:
JSCSSMixin
,BaseMultiLocation
用于在地图上绘制AntPath多段线重叠的类。
见
folium.vector_layers.path_options()
for the Path 选项。- 参数
locations (list of points (latitude, longitude)) -- 线的经纬度(北向、东向)
popup (str or folium.Popup, default None) -- 单击时,对显示的对象输入文本或可视化效果。
tooltip (str or folium.Tooltip, optional) -- 悬停在对象上时,显示文本。
**kwargs -- 折线和反路径选项。有关可用参数,请参见Github页。
https (//github.com/rubenspgcavalcante/leaflet-ant-path/) --
- default_js = [('antpath', 'https://cdn.jsdelivr.net/npm/leaflet-ant-path@1.1.2/dist/leaflet-ant-path.min.js')]¶
- class folium.plugins.BeautifyIcon(icon=None, icon_shape=None, border_width=3, border_color='#000', text_color='#000', background_color='#FFF', inner_icon_style='', spin=False, number=None, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
创建可添加到标记的美化图标
- 参数
icon (string, default None) -- 用于呈现标记的Font-Awesome图标名称。
icon_shape (string, default None) -- 图标形状
border_width (integer, default 3) -- 图标的边框宽度
border_color (string with hexadecimal RGB, default '#000') -- 图标的边框颜色
text_color (string with hexadecimal RGB, default '#000') -- 图标的文本颜色
background_color (string with hexadecimal RGB, default '#FFF') -- 图标的背景色
inner_icon_style (string with css styles for the icon, default '') -- 图标的CSS样式
spin (boolean, default False) -- 允许图标旋转。
number (integer, default None) -- 图标的编号。
示例
Plugin Website: https://github.com/marslan390/BeautifyMarker >>> BeautifyIcon(text_color='#000', border_color='transparent', ... background_color='#FFF').add_to(marker) >>> number_icon = BeautifyIcon(text_color='#000', border_color='transparent', ... background_color='#FFF', number=10, ... inner_icon_style='font-size:12px;padding-top:-5px;') >>> Marker(location=[45.5, -122.3], popup=folium.Popup('Portland, OR'), icon=number_icon) >>> BeautifyIcon(icon='arrow-down', icon_shape='marker').add_to(marker)
- ICON_SHAPE_TYPES = ['circle', 'circle-dot', 'doughnut', 'rectangle-dot', 'marker', None]¶
- default_css = [('beautify_icon_css', 'https://cdn.jsdelivr.net/gh/marslan390/BeautifyMarker/leaflet-beautify-marker-icon.min.css')]¶
- default_js = [('beautify_icon_js', 'https://cdn.jsdelivr.net/gh/marslan390/BeautifyMarker/leaflet-beautify-marker-icon.min.js')]¶
- class folium.plugins.BoatMarker(location, popup=None, icon=None, heading=0, wind_heading=None, wind_speed=0, **kwargs)¶
基类:
JSCSSMixin
,Marker
在船形中添加标记。
- 参数
location (tuple of length 2, default None) -- 标记的纬度和经度。如果没有,默认使用的是地图的中间部分。
heading (int, default 0) -- 船的航向至0到360度之间的角度值
wind_heading (int, default None) -- 风向角在0到360度之间,如果没有,则表示没有风。
wind_speed (int, default 0) -- 风速,以节为单位。
https (//github.com/thomasbrueggemann/leaflet.boatmarker) --
- default_js = [('markerclusterjs', 'https://unpkg.com/leaflet.boatmarker/leaflet.boatmarker.min.js')]¶
- class folium.plugins.CirclePattern(width=20, height=20, radius=12, weight=2.0, color='#3388ff', fill_color='#3388ff', opacity=0.75, fill_opacity=0.5)¶
基类:
JSCSSMixin
,MacroElement
由重复圆组成的多边形的填充图案。
将这些添加到GeoJson样式函数的“fillpattern”字段中。
- 参数
width (int, default 20) -- 圆之间的水平距离(像素)。
height (int, default 20) -- 圆之间的垂直距离(像素)。
radius (int, default 12) -- 每个圆的半径(像素)。
weight (float, default 2.0) -- 每个圆周围的轮廓宽度(像素)。
color (string with hexadecimal, RGB, or named color, default "#3388ff") -- 圆轮廓的颜色。
fill_color (string with hexadecimal, RGB, or named color, default "#3388ff") -- 圆圈内部的颜色。
opacity (float, default 0.75) -- 圆轮廓的不透明度。应介于0和1之间。
fill_opacity (float, default 0.5) -- 圆形内部的不透明度。应介于0和1之间。
https (See) --
- default_js = [('pattern', 'https://teastman.github.io/Leaflet.pattern/leaflet.pattern.js')]¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- class folium.plugins.Draw(export=False, filename='data.geojson', position='topleft', draw_options=None, edit_options=None)¶
基类:
JSCSSMixin
,MacroElement
Leaflet 矢量绘图和编辑插件。
- 参数
export (bool, default False) -- 添加一个小按钮,将绘制的形状导出为 geojson 文件。
filename (string, default 'data.geojson') -- Geojson文件名
position ({'topleft', 'toprigth', 'bottomleft', 'bottomright'}) -- 控制位置。看到了吗https://sportejs.com/reference-1.6.0.html控件
draw_options (dict, optional) -- 用于配置绘图工具栏的选项。请参阅http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#drawoptions
edit_options (dict, optional) -- 用于配置编辑工具栏的选项。请参阅https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#editpolyoptions
示例
>>> m = folium.Map() >>> Draw( ... export=True, ... filename='my_data.geojson', ... position='topleft', ... draw_options={'polyline': {'allowIntersection': False}}, ... edit_options={'poly': {'allowIntersection': False}} ... ).add_to(m)
欲了解更多信息,请查看 https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
- default_css = [('leaflet_draw_css', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css')]¶
- default_js = [('leaflet_draw_js', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js')]¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- class folium.plugins.DualMap(location=None, layout='horizontal', **kwargs)¶
基类:
JSCSSMixin
,MacroElement
在同一窗口中创建两个地图。
将添加的子对象添加到两个地图中。您可以访问任一地图 DualMap.m1 和 DualMap.m2.
使用 Leaflet 同步插件:https://github.com/jieter/Leaflet.Sync
- 参数
location (tuple or list, optional) -- 地图中心点的纬度和经度。
layout ({'horizontal', 'vertical'}) -- 选择两个地图的定位方式。水平(左和右)或垂直(顶部和底部)。
**kwargs -- 关键字参数传递给两个地图对象。
示例
>>> # DualMap accepts the same arguments as Map: >>> m = DualMap(location=(0, 0), tiles='cartodbpositron', zoom_start=5) >>> # Add the same marker to both maps: >>> Marker((0, 0)).add_to(m) >>> # The individual maps are attributes called `m1` and `m2`: >>> Marker((0, 1)).add_to(m.m1) >>> LayerControl().add_to(m) >>> m.save('map.html')
- add_child(child, name=None, index=None)¶
添加 child 对象到第一幅地图,然后存储到第二幅。
- default_js = [('Leaflet.Sync', 'https://cdn.jsdelivr.net/gh/jieter/Leaflet.Sync/L.Map.Sync.min.js')]¶
- fit_bounds(*args, **kwargs)¶
- keep_in_front(*args)¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- class folium.plugins.FastMarkerCluster(data, callback=None, options=None, name=None, overlay=True, control=True, show=True, icon_create_function=None, **kwargs)¶
-
使用浏览器中的渲染方式将标记簇添加到地图中。使用 FastMarkerCluster 可以比 MarkerCluster 类更快地渲染000个点。
请注意, FastMarkerCluster 类在初始化时将空列表传递给父类 class' __init__ 。这意味着永远不会调用 add_child 方法,并且不会保留对任何标记数据的引用。因此,在使用 get_bounds() 等方法时不可用。
- 参数
data (list of list with values) -- 形状列表 [[纬度,经度] , [纬度,经度] 等]使用自定义回调时,可以在lat和lon之后添加更多值。例如。 [[拉特,伦,'红'] , [lat,lon,'蓝色'] ]
callback (string, optional) -- 有效的javascript函数的字符串表示形式,将在数据中每行传递。有关自定义回调的示例,请参阅FasterMarkerCluster。
name (string, optional) -- 层的名称将显示在 LayerControls 中。
overlay (bool, default True) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
icon_create_function (string, default None) -- 覆盖默认行为,使自定义标记颜色和大小成为可能。
**kwargs -- 其他参数将传递给spleet.markercluster选项。请参阅https://github.com/spealet/spealet.markercluster
- class folium.plugins.FeatureGroupSubGroup(group, name=None, overlay=True, control=True, show=True)¶
基类:
JSCSSMixin
,Layer
创建一个要素组,该要素组在添加到地图时(例如通过 LayerControl)将其子图层添加到父组中。用于从多个叠加中创建嵌套组或簇标记。来自[0]。
[0] https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup
- 参数
group (Layer) -- 包含此子组的 MarkerCluster或 FeatureGroup。
name (string, default None) -- 层的名称,它将显示在 LayerControls 中
overlay (bool, default True) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
示例
>>> fg = folium.FeatureGroup() # Main group >>> g1 = folium.plugins.FeatureGroupSubGroup(fg, 'g1') # First subgroup of fg >>> g2 = folium.plugins.FeatureGroupSubGroup(fg, 'g2') # Second subgroup of fg >>> m.add_child(fg) >>> m.add_child(g1) >>> m.add_child(g2) >>> g1.add_child(folium.Marker([0,0])) >>> g2.add_child(folium.Marker([0,1])) >>> folium.LayerControl().add_to(m)
>>> mcg = folium.plugins.MarkerCluster(control=False) # Marker Cluster, hidden in controls >>> g1 = folium.plugins.FeatureGroupSubGroup(mcg, 'g1') # First group, in mcg >>> g2 = folium.plugins.FeatureGroupSubGroup(mcg, 'g2') # Second group, in mcg >>> m.add_child(mcg) >>> m.add_child(g1) >>> m.add_child(g2) >>> g1.add_child(folium.Marker([0,0])) >>> g2.add_child(folium.Marker([0,1])) >>> folium.LayerControl().add_to(m)
- default_js = [('featuregroupsubgroupjs', 'https://unpkg.com/leaflet.featuregroup.subgroup@1.0.2/dist/leaflet.featuregroup.subgroup.js')]¶
- class folium.plugins.FloatImage(image, bottom=75, left=75)¶
基类:
MacroElement
在地图顶部的HTML画布中添加浮动图像。
- class folium.plugins.Fullscreen(position='topleft', title='Full Screen', title_cancel='Exit Full Screen', force_separate_button=False, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
地图中添加全屏按钮。
- 参数
position (str) -- 更改按钮的位置可以是:“左上”、“右上”、“右下”或“左下”,默认值为“左上”
title (str) -- 更改按钮的标题,默认为“全屏”
title_cancel (str) -- 全屏时更改按钮的标题,默认为“退出全屏”
force_separate_button (bool, default False) -- 强制分离按钮与缩放按钮,
https (See) --
- default_css = [('Control.FullScreen.css', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.2/Control.FullScreen.min.css')]¶
- default_js = [('Control.Fullscreen.js', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.2/Control.FullScreen.min.js')]¶
- class folium.plugins.Geocoder(collapsed=False, position='topright', add_marker=True, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
一个简单的geocoder,默认情况下使用OSM/nomingim。
请遵守提名使用政策:https://operations.osmfoundation.org/policies/nominatim/
- 参数
collapsed (bool, default False) -- 如果为True,则折叠搜索框,除非悬停/单击。
position (str, default 'topright') -- 从“topleft”、“topright”、“bottomleft”或“bottomright”中选择。
add_marker (bool, default True) -- 如果为True,则在找到的位置上添加标记。
https (For all options see) --
- default_css = [('Control.Geocoder.css', 'https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css')]¶
- default_js = [('Control.Geocoder.js', 'https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js')]¶
- class folium.plugins.HeatMap(data, name=None, min_opacity=0.5, max_zoom=18, radius=25, blur=15, gradient=None, overlay=True, control=True, show=True, **kwargs)¶
基类:
JSCSSMixin
,Layer
创建热图层
- 参数
data (list of points of the form [lat, lng] or [lat, lng, weight]) -- 要绘制的点。还可以提供形状 (n,2) 或 (n,3) 的 numpy.array 。
name (string, default None) -- 层的名称将显示在 LayerControls 中。
min_opacity (default 1.) -- 热开始时的最小不透明度。
max_zoom (default 18) -- 当点达到最大强度的缩放级别(强度随缩放而缩放)时,默认为地图的最大缩放值
radius (int, default 25) -- 热图各“点”半径
blur (int, default 15) -- 模糊量
gradient (dict, default None) -- 颜色渐变配置。例如,0.4:'蓝色',0.65:'石灰',1:'红色'
overlay (bool, default True) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
- default_js = [('leaflet-heat.js', 'https://cdn.jsdelivr.net/gh/python-visualization/folium@master/folium/templates/leaflet_heat.min.js')]¶
- class folium.plugins.HeatMapWithTime(data, index=None, name=None, radius=15, min_opacity=0, max_opacity=0.6, scale_radius=False, gradient=None, use_local_extrema=False, auto_play=False, display_index=True, index_steps=1, min_speed=0.1, max_speed=10, speed_step=0.1, position='bottomleft', overlay=True, control=True, show=True)¶
基类:
JSCSSMixin
,Layer
创建一个 HeatMapWithTime 层
- 参数
data (list of list of points of the form [lat, lng] or [lat, lng, weight]) -- 要绘制的点。外部列表按顺序对应于各个时间步骤。(权重在(0,1]范围内,如果未指定点,则默认为1)
index (Index giving the label (or timestamp) of the elements of data. Should have) -- 与数据的长度相同,如果未指定,则替换为简单计数。
name (string, default None) -- 层的名称将显示在 LayerControls 中。
radius (default 15.) -- 用于热图的点周围的半径。
min_opacity (default 0) -- 热图的最小不透明度。
max_opacity (default 0.6) -- 热图的最大不透明度。
scale_radius (default False) -- 根据缩放级别缩放点的半径。
gradient (dict, default None) -- 将点密度值与颜色匹配。颜色可以是名称(“红色”)、RGB值(“RGB(255,0,0)”)或十六进制数字(“FF0000”)。
use_local_extrema (default False) -- 定义heatmap使用的是从输入数据中找到的全局极值集还是局部极值(当前视图的最大值和最小值)。
auto_play (default False) -- 自动跨时间播放动画。
display_index (default True) -- 在时间控件中显示索引(通常是时间索引)。
index_steps (default 1) -- 动画步长之间的索引尺寸所采用的步数。
min_speed (default 0.1) -- 动画的最小fps速度。
max_speed (default 10) -- 动画的最大fps速度。
speed_step (default 0.1) -- 在速度滑块上的不同fps速度之间切换。
position (default 'bottomleft') -- 时间滑块的位置字符串。格式:'下/上'+'左/右'。
overlay (bool, default True) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
- default_css = [('leaflet.timedimension.control.min.css', 'https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.control.css')]¶
- default_js = [('iso8601', 'https://cdn.jsdelivr.net/npm/iso8601-js-period@0.2.1/iso8601.min.js'), ('leaflet.timedimension.min.js', 'https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.min.js'), ('heatmap.min.js', 'https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/pa7_hm.min.js'), ('leaflet-heatmap.js', 'https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/pa7_leaflet_hm.min.js')]¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- class folium.plugins.LocateControl(auto_start=False, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
用于定位用户的控制插件。
这个插件在地图上添加了一个按钮,当它被点击时,会显示当前用户设备的位置。
要在生产环境中正常工作,需要加密连接,否则浏览器将不允许用户共享其位置。
- 参数
auto-start (bool, default False) -- 当设置为True时,插件将在地图加载和搜索用户位置时被激活。一旦建立了用户位置,地图将自动以用户坐标居中。
**kwargs -- 有关可能的选项,请参阅https://github.com/domoritz/lealet-locatecontrol
示例
>>> m = folium.Map() # With default settings >>> LocateControl().add_to(m)
#使用一些自定义选项>>>LocateControl(。。。position=“右下角”。。。strings={“title”:“见当前位置”,…“popup“:”你的位置“}).添加到(m))
有关更多信息,请查看:https://github.com/domoritz/lealet-locatecontrol
- default_css = [('Control_locate_min_css', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet-locatecontrol/0.66.2/L.Control.Locate.min.css')]¶
- default_js = [('Control_locate_min_js', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet-locatecontrol/0.66.2/L.Control.Locate.min.js')]¶
- class folium.plugins.MarkerCluster(locations=None, popups=None, icons=None, name=None, overlay=True, control=True, show=True, icon_create_function=None, options=None, **kwargs)¶
基类:
JSCSSMixin
,Layer
为地图提供了漂亮的动画标记聚类功能。
- 参数
locations (list of list or array of shape (n, 2).) -- 数据点形式为[[纬度,经度]]。
popups (list of length n, default None) -- 每个标记都得弹出,要么是弹出的对象,要么是字符串,要么就什么也没有。
icons (list of length n, default None) -- 每个标记的图标,要么是图标对象,要么是字符串,要么是什么也没有。
name (string, default None) -- 层的名称,它将显示在 LayerControls 中
overlay (bool, default True) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
icon_create_function (string, default None) -- 覆盖默认行为,使自定义标记颜色和大小成为可能。
options (dict, default None) -- 有 Leaflet.markercluster 选项的字典。有关选项,请参阅 https://github.com/Leaflet/Leaflet.markercluster for options.
示例
>>> icon_create_function = ''' ... function(cluster) { ... return L.divIcon({html: '<b>' + cluster.getChildCount() + '</b>', ... className: 'marker-cluster marker-cluster-small', ... iconSize: new L.Point(20, 20)}); ... } ... '''
- default_css = [('markerclustercss', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.1.0/MarkerCluster.css'), ('markerclusterdefaultcss', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.1.0/MarkerCluster.Default.css')]¶
- default_js = [('markerclusterjs', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.1.0/leaflet.markercluster.js')]¶
- class folium.plugins.MeasureControl(position='topright', primary_length_unit='meters', secondary_length_unit='miles', primary_area_unit='sqmeters', secondary_area_unit='acres', **kwargs)¶
基类:
JSCSSMixin
,MacroElement
在地图上添加测量小部件。
- 参数
position (str, default 'topright') -- 小部件的位置。
primary_length_unit (str, default 'meters') --
secondary_length_unit (str, default 'miles') --
primary_area_unit (str, default 'sqmeters') --
secondary_area_unit (str, default 'acres') --
https (See) --
- default_css = [('leaflet_measure_css', 'https://cdn.jsdelivr.net/gh/ljagis/leaflet-measure@2.1.7/dist/leaflet-measure.min.css')]¶
- default_js = [('leaflet_measure_js', 'https://cdn.jsdelivr.net/gh/ljagis/leaflet-measure@2.1.7/dist/leaflet-measure.min.js')]¶
- class folium.plugins.MiniMap(tile_layer=None, position='bottomright', width=150, height=150, collapsed_width=25, collapsed_height=25, zoom_level_offset=-5, zoom_level_fixed=None, center_fixed=False, zoom_animation=False, toggle_display=False, auto_toggle_display=False, minimized=False, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
将迷你地图(定位器)添加到现有地图。
在BSD 2条款“简化”许可下使用Norkart的 Leaflet 插件。https://github.com/Norkart/Leaflet-MiniMap
- 参数
tile_layer (folium TileLayer object or str, default None) -- 给定一个Folium Tilelayer对象或想要的切片作为字符串。如果没有给定,它将使用默认的“TileLayer”,即当前的 OpenStreetMap 。
position (str, default 'bottomright') -- 小部件的标准控制位置参数。
width (int, default 150) -- 小地图的宽度(像素)。
height (int, default 150) -- 小地图的高度(像素)。
collapsed_width (int, default 25) -- 折叠时切换标记和小地图的宽度(以像素为单位)。
collapsed_height (int, default 25) -- 折叠时切换标记和小地图的高度
zoom_level_offset (int, default -5) -- 与主地图的缩放相比,此偏移量应用于小地图中的缩放。可以是正的也可以是负的。
zoom_level_fixed (int, default None) -- 覆盖偏移量将固定的缩放级别应用到小地图,而不是主地图缩放。如果未设置缩放级别偏移,就会默认为任一有效的缩放级别。
center_fixed (bool, default False) -- 无论主地图的视图/位置如何,都将固定位置应用于小地图。禁止平移小地图,但可以缩放(在小地图和主地图中)。如果缩放了小地图,它将始终围绕中心的固定点缩放。您可以传入一个等效经纬度值的对象。
zoom_animation (bool, default False) -- 设置小地图是否要具有动画缩放。(将导致主地图移动后稍有滞后。)
toggle_display (bool, default False) -- 设置小地图是否要具有最小化按钮。
auto_toggle_display (bool, default False) -- 如果父本地图边界不在小地图边界内,设置小地图是否要自动隐藏。在设置“zoomLevelFixed”时尤其有用。
minimized (bool, default False) -- 设置小地图是否要在最小化位置开始。
示例
>>> MiniMap(tile_layer='Stamen WaterColor', position='bottomleft')
- default_css = [('Control_MiniMap_css', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.css')]¶
- default_js = [('Control_MiniMap_js', 'https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.js')]¶
- class folium.plugins.MousePosition(position='bottomright', separator=' : ', empty_string='Unavailable', lng_first=False, num_digits=5, prefix='', lat_formatter=None, lng_formatter=None, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
添加一个显示鼠标位置坐标的字段。
在MIT的许可下使用Ardhi Lukianto的 Leaflet 插件。 https://github.com/ardhi/Leaflet.MousePosition
- 参数
position (str, default 'bottomright') -- 小部件的标准控制位置参数。
separator (str, default ' : ') -- 用于分隔纬度和经度值的字符。
empty_string (str, default 'Unavailable') -- 要显示的初始文本。
lng_first (bool, default False) -- 是否把经度放在第一位。若设置为“真”,就会在纬度之前显示经度。
num_digits (int, default '5') -- 小数位数要包含显示的经度和纬度十进制度数值。
prefix (str, default '') -- 要在坐标前附加字符串。
lat_formatter (str, default None) -- 自定义 Javascript 函数来格式化纬度值。
lng_formatter (str, default None) -- 自定义 Javascript 函数来格式化经度值。
示例
>>> fmtr = "function(num) {return L.Util.formatNum(num, 3) + ' º ';};" >>> MousePosition(position='topright', separator=' | ', prefix="Mouse:", ... lat_formatter=fmtr, lng_formatter=fmtr)
- default_css = [('Control_MousePosition_css', 'https://cdn.jsdelivr.net/gh/ardhi/Leaflet.MousePosition/src/L.Control.MousePosition.min.css')]¶
- default_js = [('Control_MousePosition_js', 'https://cdn.jsdelivr.net/gh/ardhi/Leaflet.MousePosition/src/L.Control.MousePosition.min.js')]¶
- class folium.plugins.PolyLineOffset(locations, popup=None, tooltip=None, offset=0, **kwargs)¶
基类:
JSCSSMixin
,PolyLine
向折线类添加偏移功能。
这个插件增加了对折线多段线绘制相对像素偏移的能力,而不修改它们的实际坐标。对于左侧或右侧偏移,偏移值可以为负或正,并且在缩放级别上保持不变。
见
folium.vector_layers.path_options()
for the Path 选项。- 参数
locations (list of points (latitude, longitude)) -- 线的经纬度(北向、东向)
popup (str or folium.Popup, default None) -- 单击时,对显示的对象输入文本或可视化效果。
tooltip (str or folium.Tooltip, optional) -- 悬停在对象上时,显示文本。
offset (int, default 0) -- 相对像素偏移以固定的距离绘制平行于现有像素的线。
**kwargs -- 折线选项。有关可用参数,请参见其Github页面。
https (See) --
示例
>>> plugins.PolyLineOffset([[58, -28], [53, -23]], color="#f00", opacity=1, offset=-5).add_to(m) >>> plugins.PolyLineOffset([[58, -28], [53, -23]], color="#080", opacity=1, offset=10).add_to(m)
- default_js = [('polylineoffset', 'https://cdn.jsdelivr.net/npm/leaflet-polylineoffset@1.1.1/leaflet.polylineoffset.min.js')]¶
- class folium.plugins.PolyLineTextPath(polyline, text, repeat=False, center=False, below=False, offset=0, orientation=0, attributes=None, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
沿多段线显示文本。
- 参数
polyline (folium.features.PolyLine object) -- 要将文本附加到 folium.features.PolyLine 对象。
text (string) -- 要附加到多段线的字符串。
repeat (bool, default False) -- 指定文本是否应与多段线重复。
center (bool, default False) -- 根据多段线的边界框将文本居中
below (bool, default False) -- 在路径下显示文本
offset (int, default 0) -- 相对于多段线来说,设置偏移以定位文本。
orientation (int, default 0) -- 将文本旋转到指定角度。
attributes (dict) -- 包含应用于文本标记的属性对象。请检查以下有效属性 https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text#Attributes Example: {'fill': '#007DEF', 'font-weight': 'bold', 'font-size': '24'}
https (See) --
- default_js = [('polylinetextpath', 'https://cdn.jsdelivr.net/npm/leaflet-textpath@1.2.3/leaflet.textpath.min.js')]¶
- class folium.plugins.ScrollZoomToggler¶
基类:
MacroElement
创建用于在地图上启用/禁用滚动的按钮。
- class folium.plugins.Search(layer, search_label=None, search_zoom=None, geom_type='Point', position='topleft', placeholder='Search', collapsed=False, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
向地图中添加搜索工具。
- 参数
layer (GeoJson, TopoJson, FeatureGroup, MarkerCluster class object.) -- 要在搜索视图中用于索引的地图层。
search_label (str, optional) -- 如果层是 GeoJson/TopoJson,用于索引搜索层中的“properties”键。
search_zoom (int, optional) -- 设置的地图缩放级别要匹配。默认情况下,缩放到多边形/直线边界和其自然范围上的点。
geom_type (str, default 'Point') -- 特征几何类型。"点", "线" 或 "多边形"
position (str, default 'topleft') -- 更改搜索栏的位置,可以是:“左上”、“右上”、“右下”或“左下”,
placeholder (str, default 'Search') -- 搜索框中的占位符文本(如果未输入任何内容)。
collapsed (boolean, default False) -- 搜索框是否应折叠。
**kwargs. -- 组合样式选项可在匹配时更改功能样式。使用与向量层参数相同的方法。
https (See) --
- default_css = [('Leaflet.Search.css', 'https://cdn.jsdelivr.net/npm/leaflet-search@2.9.7/dist/leaflet-search.min.css')]¶
- default_js = [('Leaflet.Search.js', 'https://cdn.jsdelivr.net/npm/leaflet-search@2.9.7/dist/leaflet-search.min.js')]¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- test_params(keys)¶
- class folium.plugins.SemiCircle(location, radius, direction=None, arc=None, start_angle=None, stop_angle=None, popup=None, tooltip=None, **kwargs)¶
基类:
JSCSSMixin
,Marker
添加半圆形状的标记,类似于Circle类。
使用(方向和弧)或(起始角和终止角),不能同时使用。
- 参数
location (tuple[float, float]) -- 经纬度对(北距、东距)
radius (float) -- 圆的半径,单位为米。
direction (int, default None) -- 方向角(度)
arc (int, default None) -- 以度为单位的弧角。
start_angle (int, default None) -- 起始角度(度)
stop_angle (int, default None) -- 停止角度(度)。
popup (str or folium.Popup, optional) -- 单击时,对显示的对象输入文本或可视化效果。
tooltip (str or folium.Tooltip, optional) -- 悬停在对象上时,显示文本。
**kwargs -- 有关其他参数,请参见
folium.vector_layers.path_options()
https (Uses Leaflet plugin) --
- default_js = [('semicirclejs', 'https://cdn.jsdelivr.net/npm/leaflet-semicircle@2.0.4/Semicircle.min.js')]¶
- class folium.plugins.StripePattern(angle=0.5, weight=4, space_weight=4, color='#000000', space_color='#ffffff', opacity=0.75, space_opacity=0.0, **kwargs)¶
基类:
JSCSSMixin
,MacroElement
由交替线组成的多边形填充图案。
将这些添加到GeoJson样式函数的“fillpattern”字段中。
- 参数
angle (float, default 0.5) -- 线条图案的角度(度)。应该在-360度和360度之间。
weight (float, default 4) -- 主线宽度(像素)。
space_weight (float) -- 可选择的宽度(像素)。
color (string with hexadecimal, RGB, or named color, default "#000000") -- 主线的颜色。
space_color (string with hexadecimal, RGB, or named color, default "#ffffff") -- 可选线条的颜色。
opacity (float, default 0.75) -- 主线不透明度。应介于0和1之间。
space_opacity (float, default 0.0) -- 交替线的不透明度。应介于0和1之间。
https (See) --
- default_js = [('pattern', 'https://teastman.github.io/Leaflet.pattern/leaflet.pattern.js')]¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- class folium.plugins.Terminator¶
基类:
JSCSSMixin
,MacroElement
Leaflet.Terminator 是 Leaflet 库的一个简单插件,可以在地图上叠加白天和晚上的区域。
- default_js = [('terminator', 'https://unpkg.com/@joergdietrich/leaflet.terminator')]¶
- class folium.plugins.TimeSliderChoropleth(data, styledict, name=None, overlay=True, control=True, show=True)¶
基类:
JSCSSMixin
,Layer
创建一个TimeSliderChoropleth插件,以便将 Map.add_child 附加到地图中。
- 参数
data (str) -- geojson字符串
styledict (dict) -- 一种字典,其中键是 geojson 特性 id值,值是`{time: style_options_dict}`中的dict。`
name (string, default None) -- 层的名称将显示在 LayerControls 中。
overlay (bool, default False) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
- default_js = [('d3v4', 'https://d3js.org/d3.v4.min.js')]¶
- class folium.plugins.TimestampedGeoJson(data, transition_time=200, loop=True, auto_play=True, add_last_point=True, period='P1D', min_speed=0.1, max_speed=10, loop_button=False, date_options='YYYY-MM-DD HH:mm:ss', time_slider_drag_update=False, duration=None)¶
基类:
JSCSSMixin
,MacroElement
在时间戳记 GeoJSONs 中创建一个时间戳记 GeoJSONs 插件,以附加到带有 Map.add_child 的地图中。
如果出现以下情况,则 geo-json 会有时间戳记:
它只包含 LineString、MultiPoint 、MultiLineString、Polygon 和 MultiPolygon 类型的特性。
每个功能都有一个与坐标数组长度相同的“times”属性。
每个“times”属性的每个元素都是自 epoch 的 ms 或 ISO 字符串中的时间戳记。
最后,您可能具有点功能,其中“times”属性是长度为1的数组。
- 参数
data (file, dict or str.) -- 要绘制的时间戳记 geo-json 数据。*如果是文件,那么数据将被读取到文件中并完全嵌入到 Leaflet 的 javascript 中。*如果是字典,那么数据将转换为 json 并嵌入到 javascript 中。*如果是字符串,那么数据将按原样传递给 javascript 。
transition_time (int, default 200.) -- 在时间戳记之间转换的持续时间(毫秒)。
loop (bool, default True) -- 动画是否循环。
auto_play (bool, default True) -- 动画是否自动启动。
add_last_point (bool, default True) -- 是否在字符串的最后一个有效坐标处添加点。
period (str, default "P1D") -- 用于构造从第一个可用时间开始的可用时间数组。格式:ISO8601工期示例:“p1m”1/月,“p1d”1/天,“pt1h”1/小时,“pt1m”1/分钟
duration (str, default None) -- 时间段,是将此特征显示在地图上的时间段。如果没有,将显示所有以前的时间。格式:ISO8601工期示例:“p1m”1/月,“p1d”1/天,“pt1h”1/小时,“pt1m”1/分钟
示例
>>> TimestampedGeoJson({ ... 'type': 'FeatureCollection', ... 'features': [ ... { ... 'type': 'Feature', ... 'geometry': { ... 'type': 'LineString', ... 'coordinates': [[-70,-25],[-70,35],[70,35]], ... }, ... 'properties': { ... 'times': [1435708800000, 1435795200000, 1435881600000], ... 'tooltip': 'my tooltip text' ... }, ... } ... ] ... })
有关详细信息,请参阅 https://github.com/socib/Leaflet.TimeDimension for more information.
- default_css = [('highlight.js_css', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/default.min.css'), ('leaflet.timedimension_css', 'https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.control.css')]¶
- default_js = [('jquery2.0.0', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js'), ('jqueryui1.10.2', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js'), ('iso8601', 'https://cdn.jsdelivr.net/npm/iso8601-js-period@0.2.1/iso8601.min.js'), ('leaflet.timedimension', 'https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.min.js'), ('moment', 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js')]¶
- render(**kwargs)¶
呈现元素的HTML表示形式。
- class folium.plugins.TimestampedWmsTileLayers(data, transition_time=200, loop=False, auto_play=False, period='P1D', time_interval=False, name=None)¶
基类:
JSCSSMixin
,Layer
创建一个 TimestampedWmsTileLayer,它是 WmsTileLayer,并使用 Leaflet.TimeDimension 插件添加时间控件。
- 参数
data (WmsTileLayer.) -- 要添加时间支持的 WmsTileLayer 。必须像典型的 WmsTileLayer 的样式创建,并在传递给此类之前添加到地图中。
transition_time (int, default 200.) -- 在时间戳记之间转换的持续时间(毫秒)。
loop (bool, default False) -- 无论动画是否循环,默认值都需要减少WMS服务的加载时间。
auto_play (bool, default False) -- 动画是否自动启动,默认值都需要减少WMS服务的加载时间。
period (str, default 'P1D') -- 用于构造从第一个可用时间开始的可用时间数组。格式:iso8601 duration ex:'p1m'->1/月,'p1d'->1/天,'pt1h'->1/小时,'pt1m'->1/分钟。注意:这应该是被 WMS 平铺层 GetCapabilities 覆盖了。
name (string, default None) -- 层的名称将显示在 LayerControls 中。
overlay (bool, default True) -- 将层添加为可选叠加层(真)或底层(假)。
control (bool, default True) -- 请确认,层是否包含在层控件中。
show (bool, default True) -- 请确认,图层是否显示在起始位置(仅用于叠加)。
示例
>>> w0 = WmsTileLayer( ... 'http://this.wms.server/ncWMS/wms', ... name='Test WMS Data', ... styles='', ... fmt='image/png', ... transparent=True, ... layers='test_data', ... COLORSCALERANGE='0,10', ...) >>> w0.add_to(m) >>> w1 = WmsTileLayer( ... 'http://this.wms.server/ncWMS/wms', ... name='Test WMS Data', ... styles='', ... fmt='image/png', ... transparent=True, ... layers='test_data_2', ... COLORSCALERANGE='0,5', ...) >>> w1.add_to(m) >>> # Add WmsTileLayers to time control. >>> time = TimestampedWmsTileLayers([w0, w1]) >>> time.add_to(m)
有关详细信息,请参阅 https://github.com/socib/Leaflet.TimeDimension for more information.
- default_css = [('highlight.js_css', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/default.min.css'), ('leaflet.timedimension_css', 'https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.control.css')]¶
- default_js = [('jquery2.0.0', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js'), ('jqueryui1.10.2', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js'), ('iso8601', 'https://cdn.jsdelivr.net/npm/iso8601-js-period@0.2.1/iso8601.min.js'), ('leaflet.timedimension', 'https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.min.js')]¶