Select to view content in your preferred language

Click on map - SDK - WPF

843
0
06-06-2013 01:28 PM
NicolasBiboba
Emerging Contributor
Hello,

I have a very basic problem which I hope you will be able to solve.
I created a new task in arcGIS mobile 10.1.1 and I want to display a map on part of the screen and on the other part texboxes showing the coordinates of the points clicked on the map.

The problem is that I can't create a mouse event on the map : I have an unknown error and the log file does not help me. I have no idea how to skirt the problem. Maybe this is not the proper way to do it.But I precise that the method that manage the event does do the job and shows the coordinates and the error comes after. Here is the main lines of the code
                private Coordinate destination;
                private MobileCache m_mobileCache;

                // Create an instance of MobileCache, and set StoragePath
                m_mobileCache = new MobileCache();    
                m_mobileCache.StoragePath = @"mypath";
                m_mobileCache.Open();

                //Load layers from MobileCache to Mapcontrol 
                myMap.MapLayers.Add(m_mobileCache);
                
                myMap.CurrentNavigationMode = ESRI.ArcGIS.Mobile.WPF.NavigationMode.Pan;


            myMap.MouseLeftButtonDown += new MouseButtonEventHandler(myMap_MouseLeftButtonDown);

        void myMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Point pt = e.GetPosition(myMap);
            int x = (int)pt.X;
            int y = (int)pt.Y;
            destination = myMap.ToMap(x, y);
            txtLongitude.Text = System.Convert.ToString(x);
            txtLatitude.Text = System.Convert.ToString(y);
        }


And the log file :
Stack Trace:
   à Task.Page.myMap_MouseLeftButtonDown(Object sender, MouseButtonEventArgs e)
   à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   à System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   à System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
   à System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
   à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   à System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   à System.Windows.Input.InputManager.ProcessStagingArea()
   à System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   à System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   à System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   à System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

Thanks,
0 Kudos
0 Replies