Map Tip
View live sample | Download as a zip file
Description
Use "MapBase.MouseMove" to add a mouse move event. A feature's info window shows when the mouse moves into, and it disappears when the mouse move out.
How To Use
Copy and modify the codes below to meet your needs.
Code
                                <UserControl x:Class="mouseOver.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Canvas x:Name="LayoutRoot" Background="White" Margin="10, 10,10,-100">
        <Grid Visibility="Collapsed" x:Name="gd1" Canvas.ZIndex="5" Height="60" Canvas.Left="1" Canvas.Top="1" Width="100" Background="#FFE9EC8F"/>
    </Canvas>
</UserControl>

using System.Linq;
using System.Net;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml.Linq;
using SGWSilverlightAPI.Interface;
using SGWSilverlightAPI.Map;
using SGWSilverlightAPI.Layer;
using SGWSilverlightAPI.Geometry;
using SGWPolygon = SGWSilverlightAPI.Geometry.Polygon;
using SGWPoint = SGWSilverlightAPI.Geometry.Point;
using System.IO;
using System.Windows.Media.Effects;
using SGWSilverlightAPI.Navigate;
using System;



namespace mouseOver
{
    public partial class MainPage : UserControl
    {
        MapBase m_pMapBase = null;
     
        public MainPage()
        {
            InitializeComponent();
            m_pMapBase = new MapBase();
            m_pMapBase.Width = 600;
            m_pMapBase.Height = 400;

            m_pMapBase.Background = new SolidColorBrush(Colors.Green);
            LayoutRoot.Children.Add(m_pMapBase);
            CachedLayer pLayer = new CachedLayer();
            pLayer.ResourcePath = "http://sgs.supergeo.com.tw/slsagtinfowin/Agent.aspx";
            pLayer.OnLayerLoaded += OnLayerLoaded;

            m_pMapBase.AddLayer(pLayer);
            PanTool pTool = new PanTool();
            pTool.AllowDblClick = false;
            pTool.AllowWheelZoom = true;
            pTool.Initial(m_pMapBase);
            m_pMapBase.SelectMapTool(pTool);
           
            //ADD MOUSE MOVE EVENT
            m_pMapBase.MouseMove += m_pMapBase_MouseMove;
        }
        
        SGWPoint curPt = null;
        SGWPoint scrPt = null;

        void m_pMapBase_MouseMove(object sender, MouseEventArgs e)
        {
            List<ILayer> pLayers = m_pMapBase.Layers;
            MapLayer pLayer = pLayers[0] as MapLayer;
            List<innerLayer> pLayers2 = pLayer.Layers;
            innerLayer pLayer2 = pLayers2[0];

            SGWPoint pt1 = m_pMapBase.CursorPosition(e);
            scrPt = pt1;
            SGWPoint pt2 = m_pMapBase.ToMapPoint(pt1.X, pt1.Y);
            curPt = pt2;

            //PERFORM QUERY WHEN THE MOUSE MOVES INTO A FEATURE
            pLayer2.ExecuteQuery(pt2.ExportToWKT(), true, QuerySucceed, null);
            
            
            m_pMapBase.MouseMove -= m_pMapBase_MouseMove;
        }

        private void QuerySucceed(XDocument pDoc)
        {
            int kk = pDoc.ToString().Length;

            if (kk == 10) //THE MOUSE IS NOT IN ANY FEATURES.
            {
                gd1.Visibility = System.Windows.Visibility.Collapsed;
            }

            this.Dispatcher.BeginInvoke(() =>
            {
                foreach (XElement pSubElem in pDoc.Descendants("Feature"))
                {
                    // string strName = "";
                    XElement pValElem = pSubElem.Element("Values");

                    foreach (XElement pVal in pValElem.Elements())
                    {
                    }

                    XElement pGeomElem = pSubElem.Element("Geometry");
                    if (pGeomElem != null)
                    {
                        string sWKT = pGeomElem.Value;
                        
                        SGWPoint po = new SGWPoint();
                        LineString ls = new LineString();
                        SGWPolygon pg = new SGWPolygon();

                        if (sWKT.StartsWith("POINT"))
                        {
                            po.ImportFromWKT(pGeomElem.Value);
                            MessageBox.Show(po.ExportToWKT());
                        }
                        else if (sWKT.StartsWith("LINESTRING"))
                        {
                            ls.ImportFromWKT(pGeomElem.Value);
                            MessageBox.Show(ls.ExportToWKT());
                        }
                        else if (sWKT.StartsWith("POLYGON"))
                        {

                            pg.ImportFromWKT(pGeomElem.Value);

                          
                            XElement pValues = pSubElem.Element("Values");
                            //XElement pValue = pValues.Element("COUNTYNAME");
                            XElement pValue1 = pValues.Element("SOVEREIGNT");
                            XElement pValue2 = pValues.Element("POP_EST");
                            XElement pValue3 = pValues.Element("GDP_MD_EST");
                            
                            gd1.Children.Clear();
                            TextBlock tb1 = new TextBlock();
                            tb1.Text = pValue1.Value + "\nPop: " + pValue2.Value + "\nGDP: " + pValue3.Value;
                            gd1.Children.Add(tb1);
                            Canvas.SetLeft(gd1, scrPt.X - 40);
                            Canvas.SetTop(gd1, scrPt.Y - 60);
                            gd1.Visibility = System.Windows.Visibility.Visible;
                        }
                    }

                }
            });
            m_pMapBase.MouseMove += m_pMapBase_MouseMove;

        }

        private void OnLayerLoaded(object sender, EventArgs e)
        {
            Envelope pExt = m_pMapBase.Layers[0].Extent;
            ITransformation pTrans = new ScaleTransformation(1);

            m_pMapBase.Transformation = pTrans;
            Envelope pext1 = new Envelope(64.055019, 32.082678, 90.826878, 8.949713);
            m_pMapBase.ZoomMapTo(pExt);
            m_pMapBase.Scale = m_pMapBase.Scale * 2;
            m_pMapBase.RefreshMap(true);

        }
    }
}