ThinkGeo.com    |     Documentation    |     Premium Support

Centerpoint+Currentscale problem

Hi Guido,

Can you pull the latest beta015 and see if it fixed the PreserveScale and the flashing issue for you?

Thanks,
Ben

Hi Ben,
At first everything seems to be working fine.
PreserveScale shows the aerial map after mapview_loaded and the map is very smooth without flashing.

But with beta015 all my Zoom functions crash, like ZoomNederlandAsync and also the code below.
It seems like the values become out of range.

Public Sub ZoomToOverlay(ByVal Name As String)
    For Each OVL In ContentOverlays
        If OVL.Name = Name Then
            Try
                Me.CurrentExtent = OVL.GetBoundingBox
                Me.RefreshAsync()
            Catch
                MsgBox("Zoomen naar kaartlaag mislukt!", vbCritical)
            End Try
        End If
    Next
End Sub

What can I check for you to understand what’s creating this crash?

Hi Guido,

I couldn’t recreate your issue. Can you send me the error/exception you see? If possible can you enable the log as following, and send me all the logs in output window?

ThinkGeoDebugger.LogType = ThinkGeoLogType.All;
ThinkGeoDebugger.LogLevel = ThinkGeoLogLevel.All;

  1. Ideally you need to make the method async and refresh the map with await:
    await Me.RefreshAsync()
    Otherwise multiple Me.RefreshAsync() might be running concurrently.

Thanks,
Ben

Hi Ben,

This is the error/exception:
“An unhandled exception of type System.ArgumentOutOfRangeException occurred in PresentationFramework.dll
The specified argument is outside the range of valid values.”

I have included the Thinkgeo log with the ‘All’ settings and also the Call Stack.
I executed ‘ZoomNederlandAsync’ to recreate the crash.

Call Stack beta015.txt (3.3 KB)
Thinkgeo log beta015.txt (54.9 KB)

It doens’t matter if I use the aerial photo or OpenStreetMap, the same issue occurs.

I have existing tilecaches, which seem to be out of sync with the new scales ??
When I deleted the existing caches I execute ZoomNederlandAsync, it doesn’t crash but the map is empty (no aerial photo).
Zooming In and Out recreates the cache.

Deleting the cache for another overlay does not work by the way.

Seems to me like there is a mismatch between the tilecache scale and the zoomscale ?
When I empty the cache for some overlays it works untill I zoom with SHIFT/Mouse select.
After that the exception occurs.

Hi Guido,

The exception was thrown because multiple mapview.RefreshAsync() was executing concurrently. Please pull the latest beta016, where we added more check and should prevent the exception. But a better way is in your code, always await the async method; or cancel the previous drawing when the 2nd drawing kicks off.

About the tilecache, can you let me know which version worked correctly and since which version started to have issues? Can you share more of your code?

Just FYI, the map’s zoomscales and TileOverlay can be different. it will show correctly even if they are different, and the following code would sync the two:
MapView.ZoomScales = tileOverlay.TileMatrixSet.GetScales();

Thanks,
Ben

Hi Ben,

The latest beta016 is working perfectly. No exceptions and the map is showing pretty smooth.
This beta016 also works while I have not changed the RefreshAsync to be awaited yet.
(Off course I will listen to your tip and change the calls to be awaited).

Beta013 was working just fine, the first time the error occurs is in beta014.

Sharing my code is difficult, but I’m happy to inform that I easily managed to reproduce the error in de HowDoI WPF samples. Although beta016 is working, maybe this helps to optimize the code.

  1. Set the ThinkGeo version to beta014.
  2. Go to the OpenStreetMap.xaml.cs
  3. Add layerOverlay.TileCache = new FileRasterTileCache(@".\cache", “Error”); to mapview_loaded
  4. Add this function to the file:
    private void BtnTest_Click(object sender, RoutedEventArgs e)
    {
    MapView.CenterPoint = new PointShape(600000, 6820000);
    MapView.CurrentScale = 2000000;
    MapView.RotationAngle = 0;
    _ = MapView.RefreshAsync();
    }
  5. Start the application and go to OpenStreetMap. After some panning around and zooming in and out, click on the button.

I tried also with beta016 en no problem then.

I hope this helps !

Regards,
Guido

HI Guido,

I recreated the flashing issue using your demo code with beta014, and verified it’s been fixed in beta016, thanks for sharing!

Thanks,
Ben

Also Guido, I’m going to default MapResizeMode to PreserveScaleAndCenter. Please set it to PreserveScale if that’s what you prefer.

@Julian_Thoms so In the future versions (beta017 and newer) it will default to PreserveScaleAndCenter.

Thanks,
Ben