使用到的方法map.setMapStyle()。 设置地图样式,样式包括地图底图颜色和地图要素是否展示两部分
// 在百度地图容器中创建地图实例
let map = new BMap.Map("container");
// 设定地图的中心点和坐标
let point = new BMap.Point(this.centerLng, this.centerLat);
// 设置中心点坐标和地图级别
this.map.centerAndZoom(point, 15);
//去除地图要素,建筑物等标记,改变地图颜色
map.setMapStyle({
styleJson: [
// {
// featureType: "road", //道路
// elementType: "all",
// stylers: {
// color: "#ffffff",
// visibility: "off",
// },
// },
// {
// featureType: "building",
// elementType: "all",
// stylers: {
// visibility: "off",
// },
// },
// {
// featureType: "poilabel",
// elementType: "all",
// stylers: {
// visibility: "off",
// },
// },
// {
// featureType: "manmade",
// elementType: "all",
// stylers: {
// visibility: "off",
// },
// },
],
});
使用map.setMapStyle()之前地图样式如下
使用map.setMapStyle()之后地图样式如下