在Angular10中点击地图获取图层详情及其详细信息
Get the details of the layer and its details when click on the map in Angular 10
在ArcGIS地图上点击时如何获取图层的详细信息angular 10.地图上触发点击事件。例如:显示门牌号的地图。我们如何在点击地图上的其中一个门牌号时获取门牌号。我必须在我的代码中使用 'house number' 来实现其他功能。
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);
});
});
我遇到了错误,
'未捕获的类型错误:无法读取 属性 未定义的 '_view'
这取决于您想要实现的目标。例如,如果您想检索每个“可查询”层的最顶层特征,您可以使用 MapView
中的 hitTest
方法。此方法将屏幕坐标作为参数。在您的情况下,将是视图上单击事件的结果。
在ArcGIS地图上点击时如何获取图层的详细信息angular 10.地图上触发点击事件。例如:显示门牌号的地图。我们如何在点击地图上的其中一个门牌号时获取门牌号。我必须在我的代码中使用 'house number' 来实现其他功能。
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);
});
});
我遇到了错误, '未捕获的类型错误:无法读取 属性 未定义的 '_view'
这取决于您想要实现的目标。例如,如果您想检索每个“可查询”层的最顶层特征,您可以使用 MapView
中的 hitTest
方法。此方法将屏幕坐标作为参数。在您的情况下,将是视图上单击事件的结果。