Map Overlays triggering events on MapView below it

3232
4
05-04-2015 11:38 AM
DanielSabourin
New Contributor II

Hello,

I am working on upgrading a Windows Desktop touch application from the WPF 10.2.5 SDK to the .NET 10.2.5 SDK. The upgrade has gone mostly smooth, except for the transition between InfoWindow in WPF to MapOverlay in .NET. I am displaying a UserControl with some buttons and another MapView within a MapOverlay. I am also using the MapViewTap event to hide the MapOverlay if it's open. However, the problem is that the tap event (and some other events) on the MapView are triggered when tapping on the MapOverlay (and then closing it). Panning the MapView inside of the MapOverlay is a nightmare as well. This worked fine with InfoWindows on WPF SDK

Is there anyway to make it so that all of the mouse and touch events are sent to the MapOverlay, and NOT the MapView when the events are ontop of the MapOverlay?

Thanks.

0 Kudos
4 Replies
DanielSabourin
New Contributor II

This issue is mostly an issue with touch. For example, if I click on a MapOverlay, it will not trigger a MapViewTap event. However, if I use touch, the MapViewTap event will trigger.

0 Kudos
by Anonymous User
Not applicable

I am running into the same basic issue.  It is definitely touch that is the problem for me as well -- mouse clicks are fine.  It's difficult to know if this is a WPF issue or an ArcGIS Runtime issue.  Any chance you've found a work-around in the past couple of weeks?

0 Kudos
DanielSabourin
New Contributor II

My current workaround is to override the PreviewTouchDown event, determine if the touch point is on top of a MapOverlay. If it is, disable the map interaction. The UserControl that I created to put in the map overlay is "InfoWindow"

        protected override void OnPreviewTouchDown(TouchEventArgs e)

        {

            ToggleMapInteraction(e.TouchDevice.GetTouchPoint(this).Position);

            base.OnPreviewTouchDown(e);

        }

        public void ToggleMapInteraction(Point point)

        {

                MapView.InteractionOptions.IsEnabled = !point.IsOverInfoWindow(MapView);

        }

        /// <summary>

        /// walk up the visual tree to find object of type T, starting from initial object

        /// http://www.codeproject.com/Tips/75816/Walk-up-the-Visual-Tree

        /// </summary>

        public static T FindUpVisualTree<T>(this DependencyObject initial) where T : DependencyObject

        {

            DependencyObject current = initial;

            while (current != null && current.GetType() != typeof(T))

            {

                current = VisualTreeHelper.GetParent(current);

            }

            return current as T;

        }

        public static bool IsOverInfoWindow(this Point point, Visual relativeTo)

        {

            return VisualTreeHelper.HitTest(relativeTo, point).VisualHit.FindUpVisualTree<InfoWindow>() != null ? true : false;

        }

by Anonymous User
Not applicable

Thanks Daniel for posting your work-around.

0 Kudos