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

Continually requests to server

6 Answers 66 Views
Map
This is a migrated thread and some comments may be shown as answers.
Rieni De Rijke
Top achievements
Rank 1
Rieni De Rijke asked on 05 Jul 2013, 11:06 AM

I’m using a custom Tiled Provider. It seems like while zooming, the Tile Provider continually sends requests to the server, even for the zoomlevels between the wanted zoomlevel.


Ex: The map is at zoomlevel 13.
I use the mousewheel to scroll down to zoomlevel 19.
I’m not interested in zoomlevel 14-18.
This action leads to a whole lot of requests for tiles I do not need (zoomlevel 14-18), and it slows down the solution.


I even can get problems getting the tiles I will show on zoomlevel 19 because of all the loading.


Is there a way to prevent this from happening?

Could I expect the same problem when I use Bing or any other tile provider instead?

6 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 08 Jul 2013, 06:32 AM
Hello Rieni De Rijke,

This way of loading tiles is the standard behavior of the RadMap. The RadMap for Silverlight shows map tiles using the standard Silverlight MultiScaleImage control. Our own implementation of the MultiScaleImage for WPF uses a similar behavior. It is standard way to show tiles using the Deep-Zoom concept.

There is one way to show tiles for the current zoom level only. You can modify your custom provider for returning correct URIs only for current zoom level of RadMap. In other case it should return null. Also when the zoom level is changed then you should invalidate "null" tiles which were returned for this level from another levels using the MultiScaleTileSource.InvalidateTileLayer method. You can handle the RadMap.ZoomChanged event within implementation of custom TiledMapSource for this purpose.

I have attached a sample solution which implement this functionality for OpenStreet custom provider.
I hope it helps.

Regards,
Andrey Murzov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Turid Wiik
Top achievements
Rank 1
answered on 02 Aug 2013, 11:47 AM
Thank's.
This seems to work if you zoom directly from level = "Word" to level = "Neighborhood".
If you use the mousewheel to zoom, several more zoomlevels are requested.
I can see that in the output window by adding System.Diagnostics.Debug.WriteLine in Your GetTile method

 

protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)

{

     int zoomLevel = this.ConvertTileToZoomLevel(tileLevel);

     System.Diagnostics.Debug.WriteLine("GetTile zoomlevel: " + zoomLevel);

     if (this.mapZoomLevel == zoomLevel)

     {

         System.Diagnostics.Debug.WriteLine("zoomlevel == mapZoomLevel");

         string url = this.tileUrlFormat;

         url = ProtocolHelper.SetScheme(url);

         url = url.Replace("{zoom}", zoomLevel.ToString(CultureInfo.InvariantCulture));

         url = url.Replace("{x}", tilePositionX.ToString(CultureInfo.InvariantCulture));

         url = url.Replace("{y}", tilePositionY.ToString(CultureInfo.InvariantCulture));

         return new Uri(url);

     }

     else

     {

         this.RegisterTile(zoomLevel, tilePositionX, tilePositionY);

     }

     return null;

}

 

Any suggestion on this problem will be greatly appreciated.

 

0
Andrey
Telerik team
answered on 05 Aug 2013, 12:59 PM
Hi Turid Wiik,

All things work as designed. When zooming using mouse wheel the zoom level is changed incrementally so tiles from these levels will be requested. You can't change anything here when zooming using mouse wheel, because there is not strong defined target zoom level.

Regards,
Andrey Murzov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jason D
Top achievements
Rank 1
Veteran
answered on 06 Oct 2015, 03:43 PM

This has been causing me grief lately, too. Because of the amount of data we have, the data for the map is calculated for every zoom level on-demand, which can take a long time. Below is an abbreviated code example to address this. It gets the first zoom requested and the last, skipping the middle ones. If you want to ignore the first as well, maybe just stick in a timer or something in it.

Private Property ZoomLevel as Int32
Private Property Ready As Boolean
 
Private Sub moMap_ZoomChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles moMap.ZoomChanged
    If Ready Then
        Ready = False
        Do
            ZoomLevel = moMap.ZoomLevel
            DrawMap()   'Time-consuming operation
        Loop While (ZoomLevel <> moMap.ZoomLevel)
        Ready = True
    End If
End Sub

0
Martin Ivanov
Telerik team
answered on 09 Oct 2015, 02:52 PM
Hi Jason,

You can consider using the approach from the Andrey's reply. Basically, you can create a custom tile map source and return new tiles only on specific zoom levels. You can also think of an implementation that includes some kinda logic that checks if the user stopped scrolling - using a timer for example.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jason D
Top achievements
Rank 1
Veteran
answered on 09 Oct 2015, 03:36 PM

Hi Martin,

That's actually what I do. I found a bug in my code that was causing my original issue. After finding it, I removed the posted code, but am using the Dispatcher now instead. It doesn't work for all cases, but since I use a custom source, it works fine:

Windows.Application.Current.Dispatcher.Invoke(New Action(AddressOf MapDrawFinished), System.Windows.Threading.DispatcherPriority.ContextIdle)

In MapDrawFinished I check to see if the zoom is different. Not sure if this is the ideal solution but it is working for us for now.​

Tags
Map
Asked by
Rieni De Rijke
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Turid Wiik
Top achievements
Rank 1
Jason D
Top achievements
Rank 1
Veteran
Martin Ivanov
Telerik team
Share this question
or