map_style=({"style":mp_setstyle}),
map_style=({"style":'hardedge'}),
mp_setstyle='normal'
mp_setstyle='light'
mp_setstyle=dark
mp_setstyle='bluish'
mp_setstyle='grayscale'
mp_setstyle='darkgreen'
mp_setstyle='pink'
mp_setstyle='midnight'
mp_setstyle='grassgreen'
mp_setstyle='googlelite'
mp_setstyle=‘redalert’
import asyncio
# from aiohttp import TCPConnector, ClientSession
from pyecharts.charts import BMap
from pyecharts import options as opts
from pyecharts.globals import BMapType, ChartType
import requests
# 通过requests获取数据
url="https://echarts.apache.org/examples/data/asset/data/hangzhou-tracks.json"
r = requests.get(url)
data = r.json()
mp_setstyle0 = [ {
"featureType": "water",
"elementType": "geometry.fill",
"stylers": {
"color": "#ff0000ff",
"hue": "#ff0000",
"weight": "1",
"lightness": 1,
"saturation": 100,
"visibility": "on"
}
}]
mp_setstyle='redalert'
# //模板
# //默认地图样式(normal)
# //清新蓝风格(light)
# //黑夜风格(dark)
# //清新蓝绿风格(bluish)
# //高端灰风格(grayscale)
# //强边界风格(hardedge)
# //青春绿风格(darkgreen)
# //浪漫粉风格(pink)
# //午夜蓝风格(midnight)
# //自然绿风格(grassgreen)
# //精简风格(googlelite)
# //红色警戒风格(redalert)
mp_setstyle_shuiguan = [
{
"featureType": "water",
"elementType": "all",
"stylers": {"color": "#d1d1d1"},
},
{
"featureType": "land",
"elementType": "all",
"stylers": {"color": "#f3f3f3"},
},
{
"featureType": "railway",
"elementType": "all",
"stylers": {"visibility": "off"},
},
{
"featureType": "highway",
"elementType": "all",
"stylers": {"color": "#fdfdfd"},
},
{
"featureType": "highway",
"elementType": "labels",
"stylers": {"visibility": "off"},
},
{
"featureType": "arterial",
"elementType": "geometry",
"stylers": {"color": "#fefefe"},
},
{
"featureType": "arterial",
"elementType": "geometry.fill",
"stylers": {"color": "#fefefe"},
},
{
"featureType": "poi",
"elementType": "all",
"stylers": {"visibility": "off"},
},
{
"featureType": "green",
"elementType": "all",
"stylers": {"visibility": "off"},
},
{
"featureType": "subway",
"elementType": "all",
"stylers": {"visibility": "off"},
},
{
"featureType": "manmade",
"elementType": "all",
"stylers": {"color": "#d1d1d1"},
},
{
"featureType": "local",
"elementType": "all",
"stylers": {"color": "#d1d1d1"},
},
{
"featureType": "arterial",
"elementType": "labels",
"stylers": {"visibility": "off"},
},
{
"featureType": "boundary",
"elementType": "all",
"stylers": {"color": "#fefefe"},
},
{
"featureType": "building",
"elementType": "all",
"stylers": {"color": "#d1d1d1"},
},
{
"featureType": "label",
"elementType": "labels.text.fill",
"stylers": {"color": "#999999"},
},
]
map_data = [[y["coord"] for y in x] for x in data]
c=(
BMap(init_opts=opts.InitOpts(width="1200px", height="800px"))
.add_schema(
# baidu_ak="FAKE_AK",
baidu_ak="Bg8ou4zGbCvgFGXzZo00gMrc0F6ZMUdH",
center=[120.13066322374, 30.240018034923],
zoom=14,
is_roam=True,
# map_style={ "styleJson":mp_setstyle_shuiguan},
map_style=({"style":mp_setstyle}),
)
.add(
series_name="",
type_=ChartType.LINES,
data_pair=map_data,
is_polyline=True,
is_large=True,
linestyle_opts=opts.LineStyleOpts(color="purple", opacity=0.6, width=1),
effect_opts=opts.EffectOpts(trail_length=0.5),
)
.add_control_panel(
copyright_control_opts=opts.BMapCopyrightTypeOpts(position=3),
maptype_control_opts=opts.BMapTypeControlOpts(
type_=BMapType.MAPTYPE_CONTROL_DROPDOWN
),
scale_control_opts=opts.BMapScaleControlOpts(),
overview_map_opts=opts.BMapOverviewMapControlOpts(is_open=True),
navigation_control_opts=opts.BMapNavigationControlOpts(),
geo_location_control_opts=opts.BMapGeoLocationControlOpts(),
)
.render("hiking_trail_in_hangzhou1.html")
)