Hi, i get the following link How to remove all graphics from view to remove graphics from layer.
I also want to remove all polygons from graphics layer but its not working in my case as below:
//Clear all graphics
jQuery('#main').on('click', '.clear_all', function(){
view.graphics.removeAll();
});
Solved! Go to Solution.
Rajni,
Then that means the graphics are being added to a different graphics layer (GL) then. You are trying to clear the graphics in the Views graphics layer but you are adding graphics to a GraphicsLayer class var'd as "graphicsLayer" so you need to removeAl for that GL instead.
graphicsLayer.removeAll();
Do you get any errors in the browsers console? Are you sure that the graphics have been added to the views graphics and not some other graphics layer?
No error is in console. As you can see in code it is being added to graphics layer
Rajni,
Then that means the graphics are being added to a different graphics layer (GL) then. You are trying to clear the graphics in the Views graphics layer but you are adding graphics to a GraphicsLayer class var'd as "graphicsLayer" so you need to removeAl for that GL instead.
graphicsLayer.removeAll();
Ok Rob, it worked but i am using a single graphics layer which is used everywhere and added it to webmap, then how can u say it is added to different graphics layer. same webmap added to view. same graphics layer used in sketch view model. on graohicslayer newDevelopmentGraphic is also added
//
graphicsLayer = new GraphicsLayer();
webmap.add(graphicsLayer);
// Create a new instance of sketchViewModel
sketchViewModel = new SketchViewModel({
view: view,
layer: graphicsLayer,
//
graphicsLayer.addMany([newDevelopmentGraphic]);
Rajni,
What you are not understanding is that the MapView has default GraphicsLayer that is referenced by view.graphics. Thus a different GraphicsLayer then your graphicsLayer variable.
Hi Sir
Their is some time a situation arise when i clear the graphics, boundaries disappear but vertices remain.
I have found a relative link from older version, but what command should i use in 4.14 to remove vertices even.
This is the way i am clearing my all graphics, so so i need to deactivate my buttons or what some editing mode while clearing graphics.
jQuery('#main').on('click', '.clear_all', function(){
//clear all graphics added to graphics layer
clickValidation=false;
graphicsLayer.removeAll();
sketchViewModel.cancel();
});
Delete Graphic in Edit Mode Retains Vertices on Map - Possible Bug
Rajni,
You need to make sure you do not have a edit occurring before your delete all graphics. Meaning you need to do sketchViewModel.complete(); first.
yeah i have done it
//Clear all graphics
jQuery('#main').on('click', '.clear_all', function(){
//clear all graphics added to graphics layer
clickValidation=false;
sketchViewModel.complete();
sketchViewModel.cancel();
graphicsLayer.removeAll();
});
But it do not solve my problem because i keep sketchviewmodel reshape on in add graphics function
else if (event.state === "cancel" || event.state === "complete") {
//check if the graphics are done being reshaped, printout updated graphic's geometry and reshape stage.
// graphic reshaping has been completed or cancelled
sketchViewModel.update([graphic], { tool: "reshape" });
}