Skip to main content

use updateGraphicLayer to add Text to Graphic Layer

Comments

5 comments

  • Permanently deleted user

    I am trying to do the same thing.

    I created a  myTextSymbol = New ESRI.ArcGIS.Client.Symbols.TextSymbol() 

     

    myTextSymbol.Text = "This is the text"

    ..but I don't know how to complete this and call UpdateGraphicLayer Activity.

     

    Did you manage to make this work?

     

     

     

     

     

     

    0
  • Permanently deleted user
    Hi Frederic, 

     

    Here's an example that you can use for the Renderer property in the UpdateGraphicsLayer activity: ESRI.ArcGIS.Client.Renderer.FromJson("{'type':'simple','symbol':{'type':'esriTS','color':[0,0,0,255],'font':{'size':9,'style':'normal','variant':'normal','decoration':'none','weight':'normal','family':'serif'},'horizontalAlignment':'center','kerning':true,'rotated':false,'text':'SampleText','xoffset':0,'yoffset':0,'angle':0}}") The 'text':'SampleText' is the part that says what will be written.  The symbol syntax  json I got from https://developers.arcgis.com/javascript/latest/sample-code/playground/live/index.html#/config=symbols/2d/TextSymbol.json

     

     

     

    You can create the style you want there, grab the json from the bottom blue button, and pop it into this base: ESRI.ArcGIS.Client.Renderer.FromJson("{'type':'simple','symbol':{}}") Keep in mind that you'll have to change all the double quotes to either ' or "".  You'll also want to make sure that the FeatureSet property of the activity has valid geometry in the same projection as the viewer.  Here's an easy way to do a test version:

     

    _img_ alt="Text Renderer Workflow" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000fy7J&feoid=Body&refid=0EMf2000000kADv"_/_img_

     

    Hope that helps!

     

    -Amanda
    0
  • Permanently deleted user

    Excellent. 

    I worked it out too, by filling in the Renderer with:

    New ESRI.ArcGIS.Client.SimpleRenderer() With { .Symbol = New ESRI.ArcGIS.Client.Symbols.TextSymbol() With {.Text = "some text here", .FontSize = 13, .OffsetX = -10, .OffsetY = 6, .FontFamily = New System.Windows.Media.FontFamily("Arial"), .Foreground = New System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black), .FontWeight = FontWeights.Bold, .FontStyle = FontStyles.Italic}}

     

    My next question is : 

    I need to write multiple lines of text and surround it with a box.

     

    > Can I draw text that has map-height rather than "10 points font size" (and does not become enormous when I zoom out)? 

    > Can I calculate the extents of the drawn text (to caclulate a surrounding box)? 

    0
  • Permanently deleted user
    One thing I noticed while using the UpdateGraphicsLayer activity to draw multiple text symbols is that if you use the same string in the GraphicsLayer input property (like "yy" in this example) if you try to set a different message it will copy that message to all the previously placed symbols so they always say the same thing as the most recent one!  We had to put each one in their own Graphics Layer such as "yy1", "yy2", "yy3", etc. by using "yy" & layerIndex.  But this text symbol is not editable in any way so once it's placed, the user can't resize, rotate, or move it to better display in the map's whitespace.  How do we place that same text graphic as the OOTB text drawing tool?
    0
  • Permanently deleted user
    @Josh Pritt, @Frederic Poliart

     

    I've done this recently, you will need render it as Renderer.FromJson and uniqueValueRenderers to do this. Have a look the solution provide from Amanda below

     

    https://support.geocortex.com/essentialsGSCForum?sub-nav=forum&main-nav=essentials&#!/feedtype=SINGLE_QUESTION_DETAIL&criteria=ALLQUESTIONS&id=906f20000000CISAA2

     

    In order to put the text in a box, you might try "backgroundColor",  and "borderLineColor" to achieve this. You can find the Json syntax here: https://resources.arcgis.com/en/help/rest/apiref/symbol.html#ts. Though I don't know if there's a direct way to write multiple-line text, rather than just write some expression with your text and put line breaks after certain number of words.

     

     
    0

Please sign in to leave a comment.