想清楚思路很有必要!需要一個空的數組來存放準備掩膜的要素ID var map = new WebScene({ portalItem:{id:"10ede348e4c54c77b45f6ebab2d018db"} }); var view = new SceneView({ container:"v ...
想清楚思路很有必要!需要一個空的數組來存放準備掩膜的要素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 = "";
})
})