Editor widget cancelling leaves sketched internal only graphicLayers

922
1
Jump to solution
06-12-2021 02:26 PM
FranciscoCosta1
Occasional Contributor

Currently in the Editor Widget, there should be, when it is in 'awaiting-feature-to-create' status and it receives a polygon (the polyline is closed in the sketchViewModel), and it generates a feature which can get received with esriwatchUtils.when(esriweditor.viewModel.featureFormViewModel, "feature", () => {...}.

If for example we test this feature geometry and it fails to pass, when we cancel the editor using esriweditor.cancelWorkflow()  the feature is still in the view, as a GraphicsLayer (with another GraphicsLayer for boundingbox), which leaves "hanging" two internal (so they cannot be accessed using map.allLayers or mapview.allLayerViews usual methods) graphiclayers which can only be spotted if you run console.dir(map) or console.dir(view). These cannot be cleared or deleted and they are kept polluting the ui.

Example:  we are awating for users to put building footprints, would not make sense to have country polygons.

esriwatchUtils.when(esriweditor.viewModel.featureFormViewModel, "feature", () => {
if (esriweditor.viewModel.state === 'awaiting-feature-to-create') {
// validation
// max_area
let num_area = esrigeometryEngine.geodesicArea(
esriweditor.viewModel.featureFormViewModel.feature.geometry, 'square-meters'
)
if (num_area > max_area) {
alert('Warning: Maximum area accepted for a building is ' + max_area.toString());
esriweditor.cancelWorkflow()
}


Fixing suggestion: esriweditor.cancelWorkflow() should delete these internal graphiclayers which were made by its associated esriweditor.viewModel.sketchViewModel, since the Editor has been canceled and is in ready state now, and these GraphicLayers should have been propagated the cancel, as they were propagated to be created from Editor widget of course.

here is the codepen (based on https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=widgets-editor... )
https://codepen.io/engfrancis/pen/RwpeXqX 
Click Editor Add Feature > pick a polygon from templates > draw a polygon above 10.000 m2 it should not be allowed sending an alert and cancelling along. cheers.

0 Kudos
1 Solution

Accepted Solutions
FranciscoCosta1
Occasional Contributor

Ok the example here shown is one of other related to validation with Editor widget which currently are not much optimal let's say in documentation and functionality, because it was not designed having checks on users although here is working with some additional addons.

In current application used for demonstration it was sufficing for implementing validation besides the added user ui, if you guys need feedback for improving the tool from community i recommend actively check slack of esri spatial community channels for web dev cheers.

View solution in original post

0 Kudos
1 Reply
FranciscoCosta1
Occasional Contributor

Ok the example here shown is one of other related to validation with Editor widget which currently are not much optimal let's say in documentation and functionality, because it was not designed having checks on users although here is working with some additional addons.

In current application used for demonstration it was sufficing for implementing validation besides the added user ui, if you guys need feedback for improving the tool from community i recommend actively check slack of esri spatial community channels for web dev cheers.

0 Kudos