While adding vertices dynamically by ArcGIS API for Silverlight, add text instructions (use textsymbol to add multi-Text Information)

Source: Internet
Author: User
Tags silverlight

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.