Select to view content in your preferred language

Cannot update SketchViewModel polygonSymbol using Esri Loader

491
1
06-06-2022 03:05 PM
JT_Salfer
Emerging Contributor

I've encountered some pretty strange behavior trying to adjust the viewModel of the Sketch Widget. 
Following this tutorial for the SketchViewModel Styler, I've attempted to add in a custom polygonSymbol using the SketchViewModel. It works... 

JT_Salfer_3-1654552175087.gif

...to a point. It works fine with the rectangle and circle tools, but it will not work for the polygon tool until the sketch is finished, which is ultimately the what I want to target. 

JT_Salfer_4-1654552298992.gif

I can confirm this is happening in different versions of the API (4.19, 4.23), but I'm only seeing it in projects that use Esri Loader. I can create a new project that does not call the Sketch Widget or SketchViewModel via Esri Loader and it works fine. The code below is what I'm using for the sketch widget's viewModel. You can take the exact same code, plug it into the live demo at https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=sketch-geometries , and everything works as expected. The only reason I can see why this doesn't work as expected with the freehand polygon tool the way that I'm doing it is due to the presence of Esri Loader. Does anyone have a possible work around for this issue? 

 

 

    let sketchWidget = new Sketch({
        view,
        layer: sketchLayer,
        creationMode: "single",
        availableCreateTools,
        viewModel: new SketchViewModel({
          view: view,
          layer: sketchLayer,
          polygonSymbol: {
            type: "simple-fill",
            style: "cross",
            color: "#EFC8B1",
            outline: {
              width: 3,
              style: "solid",
              color: "red",
            },
          },
        }),
      });

 

 

 

 

 

 

 

0 Kudos
1 Reply
JT_Salfer
Emerging Contributor

So, I found a work around to this. Apparently the polygon tool does not use the polygonSymbol for symbology, but the polyLINESymbol when using ESRI loader. No clue why this is or how to target the inside patterning, but being able to modify the lines will suffice. 

0 Kudos