ThinkGeo.com    |     Documentation    |     Premium Support

MapView Application crashes when click on MapTools Center

Hi again

when clicking on the center of the new MapTool the hole application crashes.
Only one PostgresFeatureLayer is loaded.

System.InvalidCastException
HResult=0x80004002
Nachricht = Das Objekt des Typs “System.DBNull” kann nicht in Typ “System.Byte[]” umgewandelt werden.
Quelle = ThinkGeo.PostgreSql
Stapelüberwachung:
at ThinkGeo.Core.PostgreSqlFeatureSource.NEk=()
at ThinkGeo.Core.PostgreSqlFeatureSource.GetBoundingBoxCore()
at ThinkGeo.Core.FeatureSource.GetBoundingBox()
at ThinkGeo.Core.LayerOverlay.GetBoundingBoxCore()
at ThinkGeo.Core.PanZoomBarMapTool.70k=(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
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.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(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 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at gisMEWinFormsClient.My.MyApplication.Main(String[] Args) in :line 81

Do not know what to do…

Normal zoom functions working well. Also the move North/West/East/South of MapTool.
Doubleclick the Map also zoom ok.

Regards
Hardy

Thanks Hartwig,
The center of the new MapTool supposed to zoom to the extent which could contain all features in overlays. I did some test. It works fine.Here is my code.

 // It is important to set the map unit first to either feet, meters or decimal degrees.   
            map.MapUnit = GeographyUnit.Meter;

            // Create a new overlay that will hold our new layer and add it to the map.   
            LayerOverlay coyoteSightingsOverlay = new LayerOverlay();
            map.Overlays.Add(coyoteSightingsOverlay);

            // Create the new layer and set the projection as the data is in srid 2276 as our background is srid 3857 (spherical mercator).   
            PostgreSqlFeatureLayer coyoteSightingsLayer = new PostgreSqlFeatureLayer("User ID=thinkgeo_user;Password=cs%^%#trsdFG;Host=sampledatabases.thinkgeo.com;Port=5432;Database=thinkgeo_samples;Pooling=true;", "frisco_coyote_sightings", "id", 2276);
            coyoteSightingsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            // Add the layer to the overlay we created earlier.   
            coyoteSightingsOverlay.Layers.Add("Coyote Sightings", coyoteSightingsLayer);

            // Set a point style to zoom level 1 and then apply it to all zoom levels up to 20.   
            coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, 12, GeoBrushes.Red, new GeoPen(GeoColors.White, 2));
            coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the map view current extent to a bounding box that shows just a few sightings.     
            map.CurrentExtent = new RectangleShape(-10784283.099060204, 3918532.598821122, -10781699.527518518, 3916820.409397046);

            // Refresh the map.   
            map.Refresh();

Could you provide part of your code to help me re-produce this error.

Thanks

Frank

Hi Frank,

a part from our code is difficult because it’s about 1000+ lines.
But your way to add a postgres layer is like my.
We are using epsg 25832 for projection.

I think the function to zoom the full extent is a bit dangerous. Our Maps contains many Overlays with several layers und thousands of features. Zooming the extent may take minutes…

Am I able to configure the tool?
To enable/disable zooming the extent…

What we discovered in V12 is that there are issues with patterns and PointStyles with Images.
At the moment we test a lot and I will keep you informed which Styles (Area, Point etc.) is breaking.

Maybe there is a dependency between Styles and Extents.

Regards
Hardy

Thanks Hartwig,
You can use map.MapTools.PanZoomBar.GlobeButtonVisibility = System.Windows.Visibility.Hidden; to hide the center button.

Thanks

Frank

Hi Frank,

that’s working.

Regards
Hardy

Thanks Hartwig,
Good to know it works. Go ahead let us know if you have any more questions.

Thanks

Frank