mapbox层级变小,部分图标+文字不进行绘制问题

mapbox层级变小后,可能由于碰撞算法,有些位置的图标要素比较多时,会出现少绘制/不绘制的情况

查阅官网后,发现参数icon-ignore-placement   解释:If true, other symbols can be visible even if they collide with the icon.(如果设置成true,即使其他要素有碰撞的情况下,依然可以显示)

但是设置     icon-ignore-placement:true  后;

发现比之前绘制的要素多了,但还是没有全部绘制出来,

于是,text-allow-overlap  解释:If true, the text will be visible even if it collides with other previously drawn symbols(如果设置为true,文字依旧显示,即使和已绘制的其他要素有碰撞)

设置后,图标+文字都可以绘制出来啦

mapbox.addLayer({
        id: "id",
        type: "symbol",
        source: {
          type: "geojson",
          data: {
            type: "FeatureCollection",
            features: []
          }
        },
        paint: {
          "text-color": "white"
        },
        layout: {
          "icon-image": ["get", "icon"],
          "icon-ignore-placement": true,
          "icon-allow-overlap": true,
          "icon-size": 0.7,
          "icon-offset": [-1, -1],
          "text-field": ["get", "name"],
          "text-size": 13,
          "text-offset": [0, 0],
          "text-anchor": "top",
          "text-allow-overlap": true
        }
      });

 

上一篇:OpenGL with QtWidgets:投光物、多光源


下一篇:.net配置文件读取