Set the default line color on a sketch

481
2
Jump to solution
02-01-2023 08:04 AM
nevvo
by
New Contributor II

Hello there,

I am wanting to set the default line colour for the sketch widget in a similar fashion to this: https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-change-the-default-color-o...  but in the 4.X javascript world.

I am able to assign a color to a graphic by setting the symbol on the graphic that I can then add to a view by using:

const graphic = new Graphic({
geometry: geometry,
symbol: {
type: this.options.line.type,
color: this.options.line.color,
width: this.options.line.width
}
});

But I am not sure what I would need to default and on what object so that when I draw lines the custom color is used. 

Thanks

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

This might do what you're looking for:

sketch.viewModel.polylineSymbol =  {
	type: "simple-line", //autocasts as new SimpleLineSymbol()
	color: "red",
	width: "4px",
	style: "solid"
};

 

View solution in original post

0 Kudos
2 Replies
JoelBennett
MVP Regular Contributor

This might do what you're looking for:

sketch.viewModel.polylineSymbol =  {
	type: "simple-line", //autocasts as new SimpleLineSymbol()
	color: "red",
	width: "4px",
	style: "solid"
};

 

0 Kudos
nevvo
by
New Contributor II

That's it - thanks a lot.

0 Kudos