So we're using WPF Runtime 100.1 SDK. We want to make use of the LocationDisplay on a map view to track locations on the map. By default the datasource of the LocationDisplay is of type SystemLocationDataSource which works as expected. SystemLocationDataSource inherits from LocationDataSource which is an abstract class. Instead of using SystemLocationDataSource we have created our own custom class which inherits from LocationDataSource. Upon setting a valid location, we want to change the AutoPanMode. LocationDisplayAutoPanMode.Recenter and LocationDisplayAutoPanMode.Off works as expected. However, setting auto pan mode to LocationDisplayAutoPanMode.Navigation results in the following error:
Message=Invalid argument: Target Extent is empty.
at Esri.ArcGISRuntime.ArcGISException.HandleCoreError(CoreError error, Boolean throwException)
at RuntimeCoreNet.GeneratedWrappers.Interop.CheckError(IntPtr errorHandle, Boolean throwOnFailure, GCHandle wrapperHandle)
at RuntimeCoreNet.GeneratedWrappers.CoreGeoView.GetCurrentViewpoint(CoreViewpointType viewpointType)
at Esri.ArcGISRuntime.UI.Controls.GeoView.GetCurrentViewpoint(ViewpointType viewpointType)
at Esri.ArcGISRuntime.UI.Controls.GeoView.RunOnDispatcher(Action action)
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
I have tried this in a sample ESRI has provided on how to use the LocationDisplay property on a map view. The only thing I changed was the datasource on the LocationDisplay from SystemLocationDataSource to our custom class derived from LocationDataSource. Based on the error above, behind the scenes the LocationDisplay appears to be using the GetCurrentViewpoint method which is a method on the map view. I have tried calling this method as the map view has changed going to the navigation auto pan mode. I get the exact same error. Are there any special conditions that need to be set on a derived LocationDataSource class?
Make sure your custom LocationDataSource calls the base class UpdateLocation method with a valid coordinate. If an invalid coordinate like:
var coord = new MapPoint(double.NaN, double.NaN, spatialReference)
is passed to UpdateLocation, you'll get an error similar to what you're seeing. This tends to happen before external GPS or compass devices are fully initialized, so just check your coordinate before calling UpdateLocation and it may fix your issue.