AnsweredAssumed Answered

System.ArgumentException when using ShowCalloutForGeoElement

Question asked by ccannell on Oct 25, 2017
Latest reply on Feb 12, 2018 by MBranscomb-esristaff

I'm getting the exception below when calling ShowCalloutForGeoElement. I assume I'm doing something incorrectly but I'm unable to figure out what. If I click on the dashed line in the screenshot I receive the exception at the bottom. However, if I click on the triangle I do not get the exception. I'm using v100.1 with WPF. Any guidance would be appreciated. Thank you.

 

Code Sample:

private async void MyMapViewOnGeoViewTapped(object o, GeoViewInputEventArgs geoViewInputEventArgs)
{
  MyMapView.DismissCallout();
  foreach (var graphicsOverlay in MyMapView.GraphicsOverlays)
  {
    var result = await MyMapView.IdentifyGraphicsOverlayAsync(graphicsOverlay, geoViewInputEventArgs.Position, 10, false, 1);
    if (result.Graphics.Count >= 1)
    {
       // Create a new callout definition using the formatted string
       var myCalloutDefinition = new CalloutDefinition("Title", "Detailed text");
 
       // Display the callout
       MyMapView.ShowCalloutForGeoElement(result.Graphics[0], geoViewInputEventArgs.Position, myCalloutDefinition);
       geoViewInputEventArgs.Handled = true;
       break;
    }
  }
}

 

Screenshot:

 

 

Exception:

Exception: [10/25/2017 2:22:23 PM]     [High]     System.ArgumentException: Value does not fall within the expected range.
   at Esri.ArcGISRuntime.Geometry.GeometryUtils.ValidateSpatialReference(SpatialReference inSR1, SpatialReference inSR2, Boolean ignoreNulls)
   at Esri.ArcGISRuntime.Geometry.GeometryEngine.NearestCoordinate(Geometry geometry, MapPoint point)
   at Esri.ArcGISRuntime.UI.Controls.GeoView.<ShowCalloutForGeoElement>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at EdgeTech.OperatorConsole.App.Main()
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Value does not fall within the expected range.

Outcomes