百度地图去除地图要素,建筑物等标记

使用到的方法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()之后地图样式如下
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/sea9528/article/details/111595235