How to remove all graphics from view

4918
9
Jump to solution
10-03-2018 08:20 AM
AlexGole4
Occasional Contributor

Hi all,

Iam digging in the new API 4.X. I am not sure how to clear all graphics.

When using API 3.X we could write something like 

map.graphics.clear();

for the 4.X for individual graphics:

view.graphics.remove(graphlocate);

I was hoping there would be a but it does not seem to exist?

view.graphics.removeAll();

Any other techniques?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Alex,

  view.graphics is the Views default GraphicsLayer object.

View solution in original post

0 Kudos
9 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor
0 Kudos
AlexGole4
Occasional Contributor

right. Is there something similar for graphics though? if not, i should probably only use GLs.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

???

Graphics have to be added to a layer (either a GraphicsLayer or a FeatureLayer)....

0 Kudos
SushilPradhan
New Contributor

Hi Rob,

Can you please help me on this thread that I just posted? Your help is much

appreciated.

Regards,

-Sushil

https://community.esri.com/message/803450-customised-layer-list-widget

Hi All, I need to customize my Layer List Widget in Web AppBuilder so that

whenever a sublayer and sub-sublayers are Switched ON, the parent layer(s)

gets automatically switched ON. If anyone has any suggestion or already

developed widget, i would be glad to hear. I have layers up to 3 or 4

levels of sub-classes and I hate to click 3 or 4 times to display a single

layer.

Many thanks,

Sushil

0 Kudos
AlexGole4
Occasional Contributor

I am adding the graphics this way right now:

view.graphics.add(pointGraphic);

I have not set up any GraphisLayer like this yet

 var layerbuffer = new GraphicsLayer();
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Alex,

  view.graphics is the Views default GraphicsLayer object.

View solution in original post

0 Kudos
AlexGole4
Occasional Contributor

Ok so this should work then.

view.graphics.removeAll();
KenBuja
MVP Honored Contributor

View.graphics is a Collection, which does have a removeAll method.

AlexGole4
Occasional Contributor

Thanks Robert and Ken! 

0 Kudos