As mentioned in the previous blog, dynamic add point, address: http://blog.csdn.net/taomanman/article/details/7354103
Add text information dynamically when adding vertices as needed.
Public void addmarkergraphics () {ESRI. arcGIS. client. projection. webmercator Mercator = new ESRI. arcGIS. client. projection. webmercator (); graphicslayer = mymap. layers ["mygraphicslayer"] As graphicslayer; // Add vertex information graphic = new graphic () {geometry = Mercator. fromgeographic (New mappoint (115.257113, 33.0696150000001), symbol = layoutroot. resources ["defaultmarkersymbol"] as symbol}; graphicslayer. graphics. add (graphic); // Add text information textsymbol = new textsymbol () {fontfamily = new system. windows. media. fontfamily ("Microsoft yahei"), foreground = new system. windows. media. solidcolorbrush (color. fromargb (255,117, 20, 99), fontsize = 12, text = "the text to be added can be dynamically read and assigned as needed"}; graphic graphictext = new graphic () {geometry = Mercator. fromgeographic (New mappoint (115.257113, 33.0696150000001), symbol = textsymbol}; graphicslayer. graphics. add (graphictext );}
The textsymbol class is used to display text and add it to graphics.
If you want to add multiple text views while adding a graph tag dynamically, such as adding a value at the top of the vertex and adding a name at the bottom of the vertex, we can adjust the offsetx and offsety attributes of textsymbol to achieve the goal.
# Region watermark/rainfall value textsymbol textsymbol2 = new textsymbol () {fontfamily = new system. windows. media. fontfamily ("Microsoft yahei"), foreground = new system. windows. media. solidcolorbrush (color. fromargb (255,255, 0, 0), fontsize = 14, text = item. yl24.tostring (), offsetx = 6, offsety = 20}; graphic graphictext2 = new graphic () {geometry = Mercator. fromgeographic (New mappoint (double. parse (item. latitute. tostring (). trim (), system. globalization. cultureinfo. invariantculture), double. parse (item. longitute. tostring (). trim (), system. globalization. cultureinfo. invariantculture), symbol = textsymbol2}; graphictext. attributes ["textyl"] = item. yl24; graphicslayer. graphics. add (graphictext2); # endregion
The actual effect is as shown in Figure 5. As the map scales, the text also changes without any location deviation.