Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
get mouse poisition when hovering map element
posted

I am trying to get a silverlight popup to display near the mouse when I hover over a map element.

Is there a way of getting the mouse position from the elements symbol position?

Parents
  • 28496
    Suggested Answer
    Offline posted

    this is not exposed as a feature of the map; however, you can use the RenderTransform of the Map Viewport's RootCanvas to translate the coordinate.

         private void XamWebMap_ElementHover(object sender, MapElementHoverEventArgs e)
            {
                XamWebMap theMap = (XamWebMap)sender;
                Point pos = e.Element.ActualSymbolOrigin;
                pos = theMap.Viewport.RootCanvas.RenderTransform.Transform(pos);
                Popup pop = new Popup();
                pop.Child = new TextBlock() { Text = "hello" };
                pop.HorizontalOffset = pos.X;
                pop.VerticalOffset = pos.Y;
                pop.IsOpen = true;
            }

    alternatively, you could just use the MouseMove event, and avoid referencing any MapElement.

     

     

Reply Children
No Data