How to remove all graphics from view

9579
9
Jump to solution
10-03-2018 08:20 AM
by Anonymous User
Not applicable

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 Emeritus

Alex,

  view.graphics is the Views default GraphicsLayer object.

View solution in original post

0 Kudos
9 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
by Anonymous User
Not applicable

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

???

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

0 Kudos
SushilPradhan
New Contributor II

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
by Anonymous User
Not applicable

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 Emeritus

Alex,

  view.graphics is the Views default GraphicsLayer object.

0 Kudos
by Anonymous User
Not applicable

Ok so this should work then.

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

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

by Anonymous User
Not applicable

Thanks Robert and Ken! 

0 Kudos