Select to view content in your preferred language

Sketch Grid issue on 4.31

479
3
Jump to solution
11-15-2024 12:35 PM
DavidOke
Emerging Contributor

Hello,

We just upgraded an app to the new 4.31 version to try out the grid display in the sketch widget. I came across an issue where if I display the grid, then destroy the widget, the grid doesn't get cleaned up and becomes a permanent display feature in the map window.

Is this intended, and if so, is there a way to programmatically remove the grid from the display after the sketch widget has been destroyed.

 

Thanks!!

*Edit: Found a workaround. Check for mapview.grid. If it is not null, set it to null. This property is not apart of the map view typings.

0 Kudos
1 Solution

Accepted Solutions
JoseBanuelos
Esri Contributor

@DavidOke ,

It will be on the app to hide the grid before calling destroy on the widgets that utilize the GridControls. This means Sketch, Editor, SnappingControls, and GridControls. 

The way to hide the grid in Sketch is the following.

 

Sketch.snappingOptions.gridEnabled = false;

 

This is necessary because the grid lives in the view, and multiple widgets may be utilizing the grid. If we destroy one widget, the other widget maybe using the grid, so removing the grid would not be ideal in this scenario. We will be working on improving this experience for better widget communication, but at least for now this is how you can hide the grid.

Thanks!
Jose

View solution in original post

0 Kudos
3 Replies
JoseBanuelos
Esri Contributor

@DavidOke ,

It will be on the app to hide the grid before calling destroy on the widgets that utilize the GridControls. This means Sketch, Editor, SnappingControls, and GridControls. 

The way to hide the grid in Sketch is the following.

 

Sketch.snappingOptions.gridEnabled = false;

 

This is necessary because the grid lives in the view, and multiple widgets may be utilizing the grid. If we destroy one widget, the other widget maybe using the grid, so removing the grid would not be ideal in this scenario. We will be working on improving this experience for better widget communication, but at least for now this is how you can hide the grid.

Thanks!
Jose

0 Kudos
JoseBanuelos
Esri Contributor

@DavidOke ,
The team also would like to mention that accessing view.grid directly is not recommended. This has not been  documented yet, as the API is likely to change.

Thanks,

Jose

0 Kudos
DavidOke
Emerging Contributor

Thanks Jose! Doesn't look like setting gridEnable to false immediately removed the grid.

DavidOke_0-1732032147299.png

Got it to work doing this but not quite sure this is the best solution wrapping with requestAnimationFrame:

DavidOke_1-1732032218204.png

 

 

0 Kudos