单击Angular 10中的地图时,获取图层的详细信息及其详细信息

时间:2020-10-05 14:16:16

标签: angular arcgis arcgis-js-api angular10 esri-loader

在角度10中单击ArcGIS地图时,如何获取图层的详细信息。单击事件在地图上触发。例如:显示门牌号码的地图。单击地图上的门牌号之一时,我们如何获得门牌号。我必须在代码中使用“门牌号码”才能实现其他功能。

this._view.on('click', function (event) {
    console.log('click working');
    //Need to get the value of clicked layer.
  });

/ 更新的代码 /

this._view.on('click', function (event) {
        this._view.hitTest(event).then(function (response) {
          const graphic = response.results.filter(function (result) {
            // return result.graphic.layer === hurricanesLayer;
            return result.graphic.layer;
          })[0].graphic;
          console.log(graphic.attributes);
        });
      });

我遇到了错误, '未捕获的TypeError:无法读取未定义的属性'_view''

1 个答案:

答案 0 :(得分:0)

这取决于您要实现的目标。例如,如果要检索每个“可查询”层的最高功能,则可以使用hitTest中的MapView方法。该方法将屏幕坐标作为参数。您的情况将是视图上的click事件的结果。

这里是文档, ArcGIS API - MapView hitTest

这里有一个例子, ArcGIS Examples - Access features with pointer events