掩膜要素
想清楚思路很有必要!需要一个空的数组来存放准备掩膜的要素id
var map = new webscene({
portalitem:{id:"10ede348e4c54c77b45f6ebab2d018db"}
});
var view = new sceneview({
container:"viewdiv",
map:map
});
map.when(function(){
var scenelayer = map.layers.find(function(l){return l.title === "buildings"}); //获取房屋图层
var hidebuild = []; //新建一个空的数组用于存放掩膜房屋的id
view.on("click",function(){
view.hittest(event).then(function(response){
var graphic = response.results[0].graphic;
if(graphic && graphic.layer.title === "buildings"){
hidebuild.push(graphic.attributes.objectid);
scenelayer.definitionexpression = "objectid not in ("+hidebuild.join(",")+")";
}
})
});
document.getelementbyid("clear").addeventlistener("click",function(){
hidebuild = [];
scenelayer.definitionexpression = "";
})
})