Using ArcGIS Javascript API, we have a custom widget to allow user to select his role to analyse the data on the Map. I must display the "Role : XXXX" on top right of the Map. This should be visible to the user always. "Role: " is static & "XXXX" is dynamic as and when user changes his role. I tried using TextSymbol to display the content on the Map. TextSymbol requires "Graphic point" to be added to Graphics Layer.
var t = new TextSymbol("Role: ", font, color);
var p = new Point([-100,52]);
var g = new Graphic(p,t);
graphicsLayer.add(g);
map.addLayer(graphicsLayer);
By giving the point in graphics, the text moves along with the map as the point becomes fixed.
How do I add text to Map without map point?
Best Answer
If you just want to place some text on top of the map div, then you could add a div with absolute positioning. No need to use the API for this.
Example code: https://jsbin.com/mijariy/edit?html,output. Look for the roleInfo div, and the CSS for it.