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.
Solved! Go to Solution.
@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
@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
@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
Thanks Jose! Doesn't look like setting gridEnable to false immediately removed the grid.
Got it to work doing this but not quite sure this is the best solution wrapping with requestAnimationFrame: