Select to view content in your preferred language

Create feature using Editor widget, validate the input firstly then submit

35
0
13 hours ago
baohuachu7
Emerging Contributor

I'm using Editor widget for create features. Catch the "create" event and then validate wheter the feature is in the polygon or not. If it is not, set the invalid symbol and editor process pause.  If yes, then popup the attribute dialog.

The code not set invalid symbol sucessfully and how to set the edit process to pause state?

Code snippet:

  view.when(() => {

        const editor = new Editor({
          view: view
        });
        // Add widget to the view
        view.ui.add(editor, "top-right");
        // Add the boundary polygon  
        addGraphics();
        editor.viewModel.sketchViewModel.on("create", (evt) => {
          const graphic = evt.graphic;
          // check if the graphic is in boundary polygon 
          contains = geometryEngine.contains(boundaryPolygon, graphic.geometry);
          if (!contains) {
            graphic.symbol = invalidSymbol;
            //set invalid symbol and pause edit

           //   editor.viewModel.sketchViewModel.update([graphic], { tool: "reshape" });
          }
        });
      });

The complete code is as below:

https://codepen.io/Baohua-Chu/pen/qEdwzvb 

screenshot.png

0 Kudos
0 Replies