I am working with esri gis api for js 4.15 typescript in an Angular 9 application.
This works:
var graphic = new graphic({geometry: point, symbol:sign}):
var layer = new GraphicsLayer({id: 'mylayer'});
view.map.add(layer);
layer.when((layerdone)=>{
setInterval(()=>{
graphic.visible != graphic.visible;
}, 1000);
});
layer.add(graphic);
But this does not:
var glayer = view.map.layers.find((layer)=>{ layer.id === 'mylayer'});
var graphic = glayer.graphics.find():// lets say its found
var count = 0;
var pulser = setInterval(()=>{
graphic.visible != graphic.visible;
if((++count) >= 10){
clearInterval(pulser);
pulser = undefined;
graphic.visible = true;
}
}, 1000);
Solved! Go to Solution.
Eugene,
You had a couple of issue in your code. Notice in line 3 I return the boolean value in the find function and again in line 4 I return the boolean value. Then in line 6 I changed the way you were setting the graphics visibility.
        // click event for the button
        flashButton.addEventListener("click", function() {
          var glayer = view.map.layers.find((layer)=>{return layer.id === 'mylayer'});
          var graphic = glayer.graphics.find((gra)=>{return gra.geometry.type === 'polygon'});
          setInterval(()=>{
            graphic.visible = !graphic.visible;
          }, 1000);
        });
					
				
			
			
				
			
			
				
			
			
				
			
			
			
			
			
		Thanks Robert,
This works!!! Thanks!!!
Change from != to = ! did the trick.
Cheers to community brain trust.
Im using esri api for js 4.15.
Eugene,
You had a couple of issue in your code. Notice in line 3 I return the boolean value in the find function and again in line 4 I return the boolean value. Then in line 6 I changed the way you were setting the graphics visibility.
        // click event for the button
        flashButton.addEventListener("click", function() {
          var glayer = view.map.layers.find((layer)=>{return layer.id === 'mylayer'});
          var graphic = glayer.graphics.find((gra)=>{return gra.geometry.type === 'polygon'});
          setInterval(()=>{
            graphic.visible = !graphic.visible;
          }, 1000);
        });
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		Thanks Robert,
This works!!! Thanks!!!
Change from != to = ! did the trick.
Cheers to community brain trust.