arcgis for js 4.x 点击要素高亮显示

通常我们查看图层服务是否支持popupTemplate,然后设置显示的字段属性。

但是我们不需要显示弹出窗口,只需要高亮显示要素,应该如何操作呢

popupTemplate设置成{}

不行,仍旧会弹出窗口

设置成null,直接不高亮显示了

所以还有什么办法呢

使用highlight()就可以了

// featureLayer就是要高亮显示的图层服务
let highlight;
view.on("click", (event) => {
  view.hitTest(event).then((response) => {
    //   console.log("response:", response);
    if (highlight) highlight.remove();
    if (response.results.length) {
      let graphic = response.results.filter((result) => {
        return result.graphic.layer === featureLayer;
      })[0].graphic;
      view.whenLayerView(graphic.layer).then((layerView) => {
        highlight = layerView.highlight(graphic);
      });
    }
  });
});
posted @   槑孒  阅读(655)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
点击右上角即可分享
微信分享提示