L7Plot icon indicating copy to clipboard operation
L7Plot copied to clipboard

🐛 [BUG] 行政区划图 Choropleth 使用 update方法 更新 label.style.textAllowOverlap 不生效

Open CodingAndSleeping opened this issue 5 months ago • 8 comments

新建Choropleth 图层; 动态切换label.style.textAllowOverlap 的值; 调用update方法 不生效;

线上复现demo: demo

CodingAndSleeping avatar Jan 10 '24 06:01 CodingAndSleeping

update 变量勿使用引用更新,参考

map.update({
      label: {
        visible: true,
        field: "name",
        style: {
          fill: "#000",
          opacity: 0.8,
          fontSize: 11,
          fontWeight: "normal",
          fontFamily: "PingFang SC",
          // spacing: 4,
          stroke: "#fff",
          strokeWidth: 1.5,
          textAllowOverlap: flag,
          padding: [5, 5],
        },
      },
    });

lvisei avatar Jan 10 '24 07:01 lvisei

update 变量勿使用引用更新,参考

map.update({
      label: {
        visible: true,
        field: "name",
        style: {
          fill: "#000",
          opacity: 0.8,
          fontSize: 11,
          fontWeight: "normal",
          fontFamily: "PingFang SC",
          // spacing: 4,
          stroke: "#fff",
          strokeWidth: 1.5,
          textAllowOverlap: flag,
          padding: [5, 5],
        },
      },
    });

有点不太明白,不能赋给他一个变量吗,要给他一个具体的值?

CodingAndSleeping avatar Jan 11 '24 02:01 CodingAndSleeping

update 变量勿使用引用更新,参考

map.update({
      label: {
        visible: true,
        field: "name",
        style: {
          fill: "#000",
          opacity: 0.8,
          fontSize: 11,
          fontWeight: "normal",
          fontFamily: "PingFang SC",
          // spacing: 4,
          stroke: "#fff",
          strokeWidth: 1.5,
          textAllowOverlap: flag,
          padding: [5, 5],
        },
      },
    });

使用这种方式也只有前两次能修改,再点击就失效了

CodingAndSleeping avatar Jan 11 '24 02:01 CodingAndSleeping

update 变量勿使用引用更新,参考

map.update({
      label: {
        visible: true,
        field: "name",
        style: {
          fill: "#000",
          opacity: 0.8,
          fontSize: 11,
          fontWeight: "normal",
          fontFamily: "PingFang SC",
          // spacing: 4,
          stroke: "#fff",
          strokeWidth: 1.5,
          textAllowOverlap: flag,
          padding: [5, 5],
        },
      },
    });

有点不太明白,不能赋给他一个变量吗,要给他一个具体的值?

Immutability 了解一下

lvisei avatar Jan 11 '24 02:01 lvisei

使用这种方式也只有前两次能修改,再点击就失效了

需要直接用 L7 复现一下,再确认一下

lvisei avatar Jan 11 '24 02:01 lvisei

map.update({
      label: {
        visible: true,
        field: "name",
        style: {
          fill: "#000",
          opacity: 0.8,
          fontSize: 11,
          fontWeight: "normal",
          fontFamily: "PingFang SC",
          // spacing: 4,
          stroke: "#fff",
          strokeWidth: 1.5,
          textAllowOverlap: flag,
          padding: [5, 5],
        },
      },
    });

demo

CodingAndSleeping avatar Jan 11 '24 02:01 CodingAndSleeping

update 变量勿使用引用更新,参考

map.update({
      label: {
        visible: true,
        field: "name",
        style: {
          fill: "#000",
          opacity: 0.8,
          fontSize: 11,
          fontWeight: "normal",
          fontFamily: "PingFang SC",
          // spacing: 4,
          stroke: "#fff",
          strokeWidth: 1.5,
          textAllowOverlap: flag,
          padding: [5, 5],
        },
      },
    });

用同样的方式去修改字体大小等属性没有问题,textallowoverlap就不行

CodingAndSleeping avatar Jan 11 '24 03:01 CodingAndSleeping

使用这种方式也只有前两次能修改,再点击就失效了

更新 textAllowOverlap 不及时,需要异步触发渲染才能更新 @lzxue

L7 问题复现

lvisei avatar Jan 11 '24 08:01 lvisei