This is a migrated thread and some comments may be shown as answers.

Custom Provider tile order

4 Answers 66 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 02 Aug 2011, 08:18 PM
Using the latest internal build. I'm confused about the order in which the Custom provider loads the tile images. I assumed it would be the same way the map loads the map tiles, from OSM, for example. The tiles in view are loaded first. Then when you pan over to a new area, the new tiles are loaded. Instead what I'm seeing is that map control is loading all the tiles in sequential order and it doesn't show anything until all the tiles are loaded. It's even loading all the tiles when nothing is in view. So there can be a significant delay before any data shows up. Am I doing something wrong or is this an issue?

4 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 05 Aug 2011, 01:49 PM
Hi Jason,

The tiles are read for custom providers the same way that for OSM. The problem with delay is related to using file system for map tiles in custom provider. The tiles are downloaded using ThreadPool in separate threads, but when you use file system then the pool stops and creates each additional thread with half-second delay. You can increase the minimal number of worker thread to avoid this problem.
The sample code is below.
Dim workingThreads, completionPortThreads As Integer
ThreadPool.GetMinThreads(workingThreads, completionPortThreads)
workingThreads = 40
ThreadPool.SetMinThreads(workingThreads, completionPortThreads)

The alternative is to use the tiles cache subsystem. You can override the GetCachedTile method in your custom provider like to the following way:
Protected Overrides Function GetCachedTile(ByVal tileLevel As Integer, ByVal tilePositionX As Integer, ByVal tilePositionY As Integer) As System.IO.Stream
    Dim uri As Uri = GetTile(tileLevel, tilePositionX, tilePositionY)
    If uri <> Nothing Then
        Dim path As String = uri.LocalPath
        Dim loFileStream As New IO.FileStream(path, IO.FileMode.Open, IO.FileAccess.Read)
        Return loFileStream
    End If
    Return Nothing
End Function

Greetings,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Jason D
Top achievements
Rank 1
Veteran
answered on 05 Aug 2011, 05:32 PM
Thanks for the reply. I was already using the Caching system. I tried increasing the threads, but it didn't make a difference. I'll upload an example as a ticket later. This might be more of a feature request.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 05 Aug 2011, 11:06 PM
I had a random thought, and I finally figured out what the problem. It's drawing instantly now!

The problem was related a previous question I had here:
http://www.telerik.com/community/forums/wpf/map/multiple-mapproviders-as-layers.aspx

When you set the GeoBounds for a provider, the map acts very different. With it set, the tiles are requested one by one. I you have 1000 tiles, nothing will show on the screen until all 1000 tiles have been loaded. Also, the tiles appear to be adjusted in size to fit the GeoBounds, as the image is slightly fuzzy.

When you remove the GeoBounds, the tiles are requested correctly. Only the tiles in view are loaded. Add the image is razor sharp.

I'd suggest looking into this. I don't really see a reason right off hand for the two ways to be so different. But I'm very happy now. Thank you for all your hard work.
0
Andrey
Telerik team
answered on 10 Aug 2011, 03:25 PM
Hi Jason,

When the tiled map provider uses geobounds then for high zoom levels it could have a huge image size which will require downloading a lots of tiles. So, I would recommend to restrict the zoom level for this type providers.

Greetings,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
Map
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Andrey
Telerik team
Jason D
Top achievements
Rank 1
Veteran
Share this question
or