Select to view content in your preferred language

How to change the vertex of the polyline using SketchViewModel widget of ArcGIS Api for JS 4.x

331
7
Jump to solution
02-25-2025 02:28 AM
MirzaMuhammadAhsanAli
Occasional Contributor

Hi, @Sage_Wall ,

I wanted to change the vertex of the polyline but i didnot find any way to change the vertex of the polyline. Anybody have any idea how to do this.

here is my code in codepen
https://codepen.io/ayaxcphb-the-decoder/pen/ByaLRJq

Thank You!

0 Kudos
1 Solution

Accepted Solutions
MirzaMuhammadAhsanAli
Occasional Contributor

I change the vertex using two graphic layers one for polyline and other for custom vertex, may be it is not the best way to do it, but for now it is the only way i can find to do this.

here is the code in codepen
https://codepen.io/ayaxcphb-the-decoder/pen/ByaLRJq

MirzaMuhammadAhsanAli_0-1740550223216.png

 

View solution in original post

0 Kudos
7 Replies
Sage_Wall
Esri Regular Contributor

Hi @MirzaMuhammadAhsanAli ,

There is an optional options parameter you can pass into the update method to set the reshape tool as active.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.ht...

 sketchViewModel.update(polylineGraphic, {tool: "reshape"});

https://codepen.io/sagewall/pen/ogNzwZM

 

0 Kudos
MirzaMuhammadAhsanAli
Occasional Contributor

@Sage_Wall , Thank you for your response, I need to change the vertex symbols of the polyline, it is not changing the symbol of the vertex.

0 Kudos
Sage_Wall
Esri Regular Contributor

Sorry about that, I misunderstood the question.  I'm not so sure there is a way to change the vertex symbols. I can check in with the editing team, but I don't see an obvious way to do this.

0 Kudos
MirzaMuhammadAhsanAli
Occasional Contributor

@Sage_Wall , Thank You for your support, please let me know here if you find any way to do this.

0 Kudos
Sage_Wall
Esri Regular Contributor

@MirzaMuhammadAhsanAli,

I think the best we can do currently is change the colors with the view.theme and view.highlights.  And these properties require more recent versions than you had in your original sample code.  View.highlights wasn't introduced until yesterday 🙂 at version 4.32.  I don't think there is a way to change the symbol to a square for example but using the theme property you can change the accentColor.  I found a sample to help and updated my codepen.

https://developers.arcgis.com/javascript/latest/sample-code/view-theme/

https://codepen.io/sagewall/pen/ogNzwZM

      const view = new MapView({
        center: [-80, 35],
        container: "viewDiv",
        highlights: [{
          name: "default",
          color: "red"
        }],
        map,
        zoom: 3,
        theme: {
          accentColor: [255, 0, 0, 1],
          textColor: "red"
        }
      });
0 Kudos
MirzaMuhammadAhsanAli
Occasional Contributor

@Sage_Wall , Thank you for continuous support.

0 Kudos
MirzaMuhammadAhsanAli
Occasional Contributor

I change the vertex using two graphic layers one for polyline and other for custom vertex, may be it is not the best way to do it, but for now it is the only way i can find to do this.

here is the code in codepen
https://codepen.io/ayaxcphb-the-decoder/pen/ByaLRJq

MirzaMuhammadAhsanAli_0-1740550223216.png

 

0 Kudos