ArcGIS API fo Silverlight Learning III (using Elementlayer to implement the mouse hover bounce custom form)

Source: Internet
Author: User
Tags silverlight

Follow the previous section to continue the study, this section is mainly the use of elementlayer implementation of the mouse hover out of the definition form

Reference post: http://www.cnblogs.com/luxiaoxun/p/3322218.html

One, new Silverlight user control

Custom forms, you can place many controls, named Mymaptip.xaml, with the following code:

<grid x:name= "LayoutRoot" width= "the" height= "" background= "Transparent" >
<border cornerradius= "5" >
<Border.Background>
<solidcolorbrush color= "Black" opacity= "0.5"/>
</Border.Background>

<stackpanel margin= "5" >
<textblock foreground= "Wheat" textwrapping= "Wrap" name= "Textheadline" ></TextBlock>
<textblock foreground= "Wheat" textwrapping= "Wrap" name= "texteffective" ></TextBlock>
<textblock foreground= "Wheat" textwrapping= "Wrap" name= "Textdescription" ></TextBlock>

</StackPanel>

</Border>

</Grid>

The background code is:

Public Mymaptip (string effective, string headline, String DESCRIPTION)
{
InitializeComponent ();
Texteffective.text = "Release time:" + effective;
Textheadline.text = "title:" + headline;
Textdescription.text = DESCRIPTION;
}

Second, implement the custom form popup

1. Define Global variables: elementlayer elementlayer = new ESRI. ArcGIS.Client.ElementLayer ();

2, load Elementlayer in the map (preferably placed after loading graphicslayer, layer loading order: After loading in the upper layer):

THIS.MYMAP.LAYERS.ADD (Elementlayer);

3. Add properties for graphic and increase mouse events for Graphicslayer

private void Addlightmarker ()
{
Graphicslayer Glayer = new ESRI. ArcGIS.Client.GraphicsLayer ();
Graphic g = new Graphic ()
{
Geometry = Mercator. Fromgeographic (New MapPoint (108.2, 37.1)),
Symbol = layoutroot.resources["Strobemarkersymbol"] as Symbol
};
G.attributes.add ("Effective", "helllo!");
G.attributes.add ("headline", "FDAFADFAF");
G.attributes.add ("DESCRIPTION", "BADFADFAFAF");
Glayer. Graphics.add (g);

THIS.MYMAP.LAYERS.ADD (Glayer);

Mouse Hover Events
Glayer. MouseEnter + = Glayer_mouseenter;
Mouse Move Event
Glayer. MouseLeave + = Glayer_mouseleave;
}

4. Handling mouse events, displaying custom forms

void Glayer_mouseleave (object sender, ESRI. ArcGIS.Client.GraphicMouseEventArgs e)
{
ElementLayer.Children.Clear ();
throw new System.NotImplementedException ();
}

void Glayer_mouseenter (object sender, ESRI. ArcGIS.Client.GraphicMouseEventArgs e)
{
Graphic g = e.graphic;

ElementLayer.Children.Clear (); Clear the previous display screen
Mymaptip Infowindow = new Mymaptip (g.attributes["effective"]. ToString (), g.attributes["headline"]. ToString (), g.attributes["DESCRIPTION"]. ToString ()); Instantiate an interface
Projected coordinate system converted to geographic coordinate system (from wkid=102100 to wkid=4326)
MapPoint MapPoint = Mercator. Togeographic (G.geometry as ESRI. ArcGIS.Client.Geometry.MapPoint) as MapPoint;
Set this parameter to control where the diagram is displayed
Elementlayer.setenvelope (Infowindow, New Envelope (Mappoint.x, Mappoint.y, Mappoint.x, Mappoint.y));
ELEMENTLAYER.CHILDREN.ADD (Infowindow); Add an interface to Elementlayer
throw new System.NotImplementedException ();
}

ArcGIS API fo Silverlight Learning III (using Elementlayer to implement the mouse hover bounce custom form)

Related Article

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.