ThinkGeo.com    |     Blog    |     Wiki    |     Support

ThinkGeo V12 - mapView.Refresh Exception

ThinkGeo Team,

With the below code an exception as shown below is encountered on the mapView.Refresh.

I have the same code in MapSuite application and it does not encounter an exception.

I realize the LayerOverlay does not have a layer but neither does it at this point in my MapSuite applications. The Layers are loaded later after the layers that need to be loaded are known.

Would you change this so it behaves like MapSuite please?

Thanks,
Dennis

LayerOverlay TheLayerOverlay;

// set map unit
mapView.MapUnit = GeographyUnit.Meter;

// instantiate the LayerOverlay
TheLayerOverlay = new LayerOverlay();
TheLayerOverlay.Name = string.Format("{0}", "TheLayerOverlay");
TheLayerOverlay.TileBuffer = 1;
TheLayerOverlay.TileWidth = 1920;
TheLayerOverlay.TileHeight = 1200;
TheLayerOverlay.TileType = TileType.MultiTile;

// load the LayerOverlay
mapView.Overlays.Add(TheLayerOverlay);

// refresh
mapView.Refresh();



System.ArgumentNullException
  HResult=0x80004003
  Message=The parameter you supplied may not be null. (Parameter 'worldExtent')
  Source=ThinkGeo.Core
  StackTrace:
   at ThinkGeo.Core.ValidatorHelper.CheckObjectIsNotNull(Object parameterObject, String parameterName)
   at ThinkGeo.Core.MapUtil.GetScale(GeographyUnit mapUnit, RectangleShape boundingBox, Double widthInPixel, Double heightInPixel, Single dpi)
   at ThinkGeo.UI.Wpf.MapView.GetSnappedZoomLevelIndex(RectangleShape targetExtent)
   at ThinkGeo.UI.Wpf.MapView.GetSnappedExtent(RectangleShape extent)
   at ThinkGeo.UI.Wpf.MapView.50Q=()
   at ThinkGeo.UI.Wpf.MapView.get_CurrentExtent()
   at ThinkGeo.UI.Wpf.MapView.Refresh(OverlayRefreshType refreshType)
   at OriStarPrototype.MainWindow.MapViewLoaded(Object sender, RoutedEventArgs e) in C:\OriStarMappingIncThinkGeoUI-V12.1\OriStarPrototype\MainWindow.xaml.cs:line 87
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
   at System.Windows.Interop.HwndTarget.OnResize()
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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)

Hi Dennis,

Thanks to let us know your questions.

In version 12 if your map don’t contains valid layer and you had’t set the current extent, map refresh will throw exception to let user know it.

To solve it please set current extent or add a valid layer in your map, for example:

    mapView.CurrentExtent = new RectangleShape(-180, 90, 180, -90); // Decimal degree
    mapView.CurrentExtent = new RectangleShape(-20000000, 20000000, 20000000, -20000000); // Meter

In previous version, empty overlay will still create a WPF control based on a default extent, it cause performance issues in some scenarios. In new version, the empty overlay won’t get created.

Any question please feel free to let us know.

Regards,

Ethan