js API 4.8高亮显示

在mapView中采用FeatureLayerView 中的highlight()方法是图形单击高亮,代码如下:var highlight;
view.on("click",function(event){
if(highlight){
highlight.remove();
}
view.hitTest(event).then(function(response){
if(response.results[0]){
var graphic = response.results[0].graphic;
view.whenLayerView(graphic.layer).then(function(lyrView){
console.log(lyrView)
highlight = lyrView.highlight(graphic);
console.log(highlight)
})
}
})
});
也开启了webgl的渲染, var dojoConfig = {
has: {
"esri-featurelayer-webgl": 1
}
};为什么还是没有作用啊?
已邀请:

许丹石

赞同来自:

        var featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6 ... ot%3B
});
var highlight;
view.on("click",function(event){
if(highlight){
highlight.remove();
}
view.hitTest(event).then(function(response){
if(response.results[0]){
var graphic = response.results[0].graphic;
view.whenLayerView(graphic.layer).then(function(lyrView){
highlight = lyrView.highlight(graphic);
})
}
})
});

map.add(featureLayer);
参考这个,是能高亮的

要回复问题请先登录注册