Add Text to the Sketch Widget

2234
3
Jump to solution
10-19-2021 08:53 AM
MichaelBoschert
Occasional Contributor

Hey,

i would like to offer the users the possibility to add some text to the map.
I tried with the following code https://community.esri.com/t5/arcgis-api-for-javascript-questions/how-to-add-draw-widget-along-with-...

That's works fine but it's done for API4.9, not 4.21. When changing to 4.21 in the "<script> part" it runs into an error or several functions don't work well.I tried to figure out the difference for a while but didn't find any solution.

Can someone help me? Maybe someone also finds an easier or another way to realize my issue...

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

What is your goal? You can use Map Notes to quickly add text to the map:

https://developers.arcgis.com/javascript/latest/sample-code/layers-mapnoteslayer/

You can also extend the Sketch widget using the ViewModel, and assign a TextSymbol to the pointSymbol property:

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

 

View solution in original post

3 Replies
Noah-Sager
Esri Regular Contributor

What is your goal? You can use Map Notes to quickly add text to the map:

https://developers.arcgis.com/javascript/latest/sample-code/layers-mapnoteslayer/

You can also extend the Sketch widget using the ViewModel, and assign a TextSymbol to the pointSymbol property:

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

 

MichaelBoschert
Occasional Contributor

Thanks @Noah-Sager  

My goal is to create a sketch widget with the possibility to add notes to the map using the API 4.21 - not 4.9 as it was used in my example.

All in one exactly what your example does... Thanks a lot, this will work for me!

 

Noah-Sager
Esri Regular Contributor

Glad to hear it @MichaelBoschert. Please feel free to mark my post as the solution if it answered your question. 

0 Kudos