参考:python高德地图可视化_【可视化】python地图可视化_Folium
参考:Folium 0.12.1 documentation »Quickstart
瓦片修改:
点线面显示举例
Polygon 通过 weight 调整边界线的宽度
import folium
# 用于 MarkerCluster
import folium.plugins
# 加载高德地图瓦片
m=folium.Map(location=[40.00727, 116.486635],
zoom_start=17,
tiles='http://webst04.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}',
attr='default')
# 单点,直接加入坐标即可
folium.Marker(
[40.00777, 116.486635],
popup=folium.Popup('望京科创园',max_width=1000),
tooltip='click here').add_to(m)
# 多边形,需要所有的点,可以填充颜色
folium.Polygon(
[[40.00777, 116.485635],
[40.00697, 116.488035],
[40.00877, 116.487635]],
color='red',
fill_color='red',
fillOpacity=0.5).add_to(m)
# 折线,需要所有的点,只有颜色
folium.PolyLine(
[[40.00677, 116.485635],
[40.00597, 116.488035],
[40.00777, 116.487635]],
color='green').add_to(m)
# 圆圈显示
folium.Circle(
[40.00677, 116.485635],
50,
color='purple',
fill_color='purple',
fillOpacity='purple').add_to(m)
folium.CircleMarker(
location=[40.00597, 116.488035],
radius=20,
popup="Laurelhurst Park",
color="#3186cc",
fill=True,
fill_color="#3186cc",
).add_to(m)
# 显示点集
folium.plugins.MarkerCluster(
locations=[[40.00677, 116.485635],
[40.00597, 116.488035],
[40.00777, 116.487635]],).add_to(m)
m
显示效果如下:

部分语法如下所示:
Init signature:
folium.Marker(
location=None,
popup=None,
tooltip=None,
icon=None,
draggable=False,
**kwargs,
)
Docstring:
Create a simple stock Leaflet marker on the map, with optional
popup text or Vincent visualization.
Parameters
----------
location: tuple or list
Latitude and Longitude of Marker (Northing, Easting)
popup: string or folium.Popup, default None
Label for the Marker; either an escaped HTML string to initialize
folium.Popup or a folium.Popup instance.
tooltip: str or folium.Tooltip, default None
Display a text when hovering over the object.
icon: Icon plugin
the Icon plugin to use to render the marker.
draggable: bool, default False
Set to True to be able to drag the marker around the map.
Init signature: folium.Polygon(locations, popup=None, tooltip=None, **kwargs)
Docstring:
Draw polygon overlays on a map.
See :func:`folium.vector_layers.path_options` for the `Path` options.
Parameters
----------
locations: list of points (latitude, longitude)
Latitude and Longitude of line (Northing, Easting)
popup: string or folium.Popup, default None
Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, default None
Display a text when hovering over the object.
**kwargs
Other valid (possibly inherited) options. See:
https://leafletjs.com/reference-1.6.0.html#polygon
Init signature: folium.PolyLine(locations, popup=None, tooltip=None, **kwargs)
Docstring:
Draw polyline overlays on a map.
See :func:`folium.vector_layers.path_options` for the `Path` options.
Parameters
----------
locations: list of points (latitude, longitude)
Latitude and Longitude of line (Northing, Easting)
popup: str or folium.Popup, default None
Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, default None
Display a text when hovering over the object.
smooth_factor: float, default 1.0
How much to simplify the polyline on each zoom level.
More means better performance and smoother look,
and less means more accurate representation.
no_clip: Bool, default False
Disable polyline clipping.
**kwargs
Other valid (possibly inherited) options. See:
https://leafletjs.com/reference-1.6.0.html#polyline
Init signature:
folium.CircleMarker(
location=None,
radius=10,
popup=None,
tooltip=None,
**kwargs,
)
Docstring:
A circle of a fixed size with radius specified in pixels.
See :func:`folium.vector_layers.path_options` for the `Path` options.
Parameters
----------
location: tuple[float, float]
Latitude and Longitude pair (Northing, Easting)
popup: string or folium.Popup, default None
Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, default None
Display a text when hovering over the object.
radius: float, default 10
Radius of the circle marker, in pixels.
**kwargs
Other valid (possibly inherited) options. See:
https://leafletjs.com/reference-1.6.0.html#circlemarker
Init signature:
folium.plugins.MarkerCluster(
locations=None,
popups=None,
icons=None,
name=None,
overlay=True,
control=True,
show=True,
icon_create_function=None,
options=None,
**kwargs,
)
Docstring:
Provides Beautiful Animated Marker Clustering functionality for maps.
Parameters
----------
locations: list of list or array of shape (n, 2).
Data points of the form [[lat, lng]].
popups: list of length n, default None
Popup for each marker, either a Popup object or a string or None.
icons: list of length n, default None
Icon for each marker, either an Icon object or a string or None.
name : string, default None
The name of the Layer, as it will appear in LayerControls
overlay : bool, default True
Adds the layer as an optional overlay (True) or the base layer (False).
control : bool, default True
Whether the Layer will be included in LayerControls.
show: bool, default True
Whether the layer will be shown on opening (only for overlays).
icon_create_function : string, default None
Override the default behaviour, making possible to customize
markers colors and sizes.
options : dict, default None
A dictionary with options for Leaflet.markercluster. See
https://github.com/Leaflet/Leaflet.markercluster for options.
热力图显示(超级简单)
参考:https://www.cnblogs.com/feffery/p/9288138.html
# 分别显示凸包 以及 所有点
m=folium.Map(location=[40.001971, 116.47304],
zoom_start=18,
tiles='http://webst04.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}',
attr='default')
# 显示 polygon
folium.Polygon(tmp_hull, color='red', fill_color='red').add_to(m)
for i in range(len(pts)):
folium.CircleMarker(pts[i], 1, color='purple').add_to(m)
folium.plugins.HeatMap(pts).add_to(m)
m
