Completed
Last Updated: 22 Feb 2018 12:36 by Dimitar
ADMIN
Hristo
Created on: 20 Feb 2018 11:44
Category: Map
Type: Bug Report
2
FIX. RadMap - incorrect tiles location using the LocalMapProvider at different zoom levels
Workaround:
Public Class MyLocalMapProvider
    Inherits LocalMapProvider

    Public Overrides Sub ViewportChanged(viewport As IMapViewport, action As ViewportChangeAction)
        If Not Me.Initialized Then
            Me.Initialize()

            Return
        End If

        Dim tilesToDraw As List(Of MapVisualElement) = DirectCast(Me.GetType().BaseType.GetField("tilesToDraw", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me), List(Of MapVisualElement))

        Dim numOfTilesX As Integer = CInt(Math.Ceiling(CDbl((viewport.ViewportInPixels.Width)) / Me.TileSize.Width)) + 2
        Dim numOfTilesY As Integer = CInt(Math.Ceiling(CDbl((viewport.ViewportInPixels.Height)) / Me.TileSize.Height)) + 2
        Dim maxNumberOfTilesY As Integer = If((viewport.ZoomLevel = 1), 2, (viewport.ZoomLevel - 1) << 2)
        numOfTilesY = Math.Min(numOfTilesY, maxNumberOfTilesY)

        Dim topLeftTile As Point = MapTileSystemHelper.PixelXYToTileXY(-viewport.PanOffset.Width, -viewport.PanOffset.Height)

        Dim numberOfTiles As Integer = 2 << (viewport.ZoomLevel - 1)
        Dim startX As Integer = CInt(viewport.PanOffset.Width) Mod Me.TileSize.Width
        Dim startY As Integer = CInt(viewport.PanOffset.Height) Mod Me.TileSize.Height

        If startX > 0 Then
            startX -= Me.TileSize.Width
        End If

        For i As Integer = 0 To numOfTilesY - 1
            For j As Integer = 0 To numOfTilesX - 1
                Dim x As Integer = startX + j * Me.TileSize.Width
                Dim y As Integer = startY + i * Me.TileSize.Height

                Dim tileX As Integer = (topLeftTile.X + j) Mod numberOfTiles
                Dim tileY As Integer = (topLeftTile.Y + i) Mod numberOfTiles

                If tileX < 0 Then
                    tileX += numberOfTiles
                End If

                tilesToDraw.Add(New MapTile(Me.GetTileImage(tileX, tileY, viewport.ZoomLevel), New Rectangle(New Point(x, y), Me.TileSize)))
            Next
        Next
    End Sub
End Class
0 comments