欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

掩膜要素

程序员文章站 2024-01-30 11:03:16
想清楚思路很有必要!需要一个空的数组来存放准备掩膜的要素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 = "";

  })

})