0
点赞
收藏
分享

微信扫一扫

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);
});
}
});
});

箴言:因为这些东西是非常简单的。不要抱怨自己学不会,那是因为你没有足够用心。



举报

相关推荐

0 条评论