コード例 #1
0
def test_bmap_map_control_panel(fake_writer):
    bmap = (BMap().add_schema(
        baidu_ak=FAKE_API_KEY, center=[
            -0.118092, 51.509865
        ]).add_coordinate("London", -0.118092, 51.509865).add(
            "bmap",
            [list(z) for z in zip(TEST_LOCATION, TEST_VALUE)],
            type_=ChartType.LINES,
            label_opts=opts.LabelOpts(formatter="{b}"),
        ).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(),
        ))
    bmap.render()
    content = fake_writer.call_args[0][1]
    assert_in("new BMap.CopyrightControl", content)
    assert_in("new BMap.MapTypeControl", content)
    assert_in("new BMap.ScaleControl", content)
    assert_in("new BMap.OverviewMapControl", content)
    assert_in("new BMap.NavigationControl", content)
    assert_in("new BMap.GeolocationControl", content)
コード例 #2
0
                 })
    coord = prepare_coord(load_street_pickle())
    for s, (long, lat) in coord.items():
        m.add_coordinate(s, long, lat)
    speed, n_slice = read_speed()
    # Match T-GCN expand 3 times... (don't know why)
    idx_map = list(range(0, 114 - 12 - 3 - 1)) + list(range(114, 143 - 12 - 3))
    pred_speed, n_slice1 = read_pred_speed()
    assert len(idx_map) == n_slice1
    m.add(series_name="actual",
          type_="heatmap",
          data_pair=get_data_pair(speed, 0)).add(
              series_name="predict",
              type_="heatmap",
              data_pair=get_data_pair(pred_speed, 0),
          ).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(),
          ).set_global_opts(
              visualmap_opts=opts.VisualMapOpts(
                  min_=0,
                  max_=60,
                  range_color=['blue', 'blue', 'green', 'yellow', 'red']),
              title_opts=opts.TitleOpts(title="Traffic Status of Xi'An"))
    m.render('test.html')
コード例 #3
0
            # position=0,  # 等同于anchor_top_left,1、2、3分别为右上,左下,右下
            # offset_height=50,  # 距离上部偏移量
            # offset_width=10,  # 距离左右偏移量
            is_open=True,
        ),
        opts.BMapScaleControlOpts(  # 比例尺控件
            # position=0,  # 等同于anchor_top_left,1、2、3分别为右上,左下,右下
            # offset_height=50,  # 距离上部偏移量
            # offset_width=10,  # 距离左右偏移量
        ),
        opts.BMapTypeControlOpts(  # 切换地图类型的控件
            # position=0,
            type_=2,  # MAPTYPE_CONTROL_HORIZONTAL/DROPDOWN/MAP,按钮水平方式展示为0,下拉列表为1,图片方式为2(设置该类型后无法指定 maptypes 属性)
        ),
        opts.BMapCopyrightTypeOpts(  # 版权控件,您可以在地图上添加自己的版权信息
            # position=0,
            # offset_height=50, # 距离上部偏移量
            # offset_width=10,  # 距离左右偏移量
            copyright_="made by shh",  # Copyright 的文本内容, 可以放入 HTML 标签
        ),
        opts.BMapGeoLocationControlOpts(  # 地图定位的控件,使用 HTML5 浏览器定位功能
            # position=0,
            # offset_height=50, # 距离上部偏移量
            # offset_width=10,  # 距离左右偏移量
            is_show_address_bar=True,  # 是否显示定位信息面板。默认显示定位信息面板
            is_enable_auto_location=True,  # 添加控件时是否进行定位。默认添加控件时不进行定位
        )
    )
        .render("e:/python_out/air_quality_baidu_map.html")
)