掩膜要素
2019-02-22 14:51 yangol 阅读(266) 评论(0) 编辑 收藏 举报想清楚思路很有必要!需要一个空的数组来存放准备掩膜的要素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 = "";
})
})