Completed
Last Updated: 09 Jan 2020 16:06 by ADMIN
Release R1 2020
James
Created on: 08 Jan 2020 05:48
Category: Map
Type: Bug Report
1
RadMap:OpenStreetMap provider does not follow the latest OpenStreetMap tile usage policy requiring UserAgent header

Recently OpenStreetMap changed their tile usage policy and require UserAgent string in the web headers for accessing tile.openstreetmap.org tiles.

https://operations.osmfoundation.org/policies/tiles/

As a result, standard open street map mode does not work - no tiles are loaded and "too many requests" error is returned from the server.

RadMap's OpenStreetMapProvider needs API (event, property or similar) for easier set up of UserAgent / Referer / other headers of web requests.

 

4 comments
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 09 Jan 2020 16:06

Hello, James,

As it was stated in Dimitar's reply, this functionality will be available as of R1 2020. The official release is scheduled for the middle of January.

Meanwhile, feel free to use the suggested workaround with the custom MapTileDownloader.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
James
Posted on: 09 Jan 2020 15:37

Dimitar, the "WebHeaders" keyword prompts a design-time error:

 

tileDownloader.WebHeaders.Add(System.Net.HttpRequestHeader.UserAgent, "your application name");

 

Is there an assembly reference that is needed to run this?  For context, Dess' solution below worked for me.

 

Thanks!

ADMIN
Dimitar
Posted on: 09 Jan 2020 12:46

Hello,

The tile usage policy of the OpenStreetMaps has changed recently to require UserAgent header in the web request for downloading map tiles.
Our RadMap's OpenStreetMap provider does not set such default header, and it should be set per application.

As of  R1 2020 you must specify the User Agent as follows:
string cacheFolder = @"..\..\cache";
OpenStreetMapProvider osmProvider = new OpenStreetMapProvider();
MapTileDownloader tileDownloader = osmProvider.TileDownloader as MapTileDownloader;
tileDownloader.WebHeaders.Add(System.Net.HttpRequestHeader.UserAgent, "your application name");
LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
osmProvider.CacheProvider = cache;
this.radMap1.MapElement.Providers.Add(osmProvider);

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 08 Jan 2020 07:02

Hi, James,

Currently, the possible solution that I can suggest is to specify the HttpRequestHeader.UserAgent in the MapTileDownloader:

        public RadForm1()
        {
            InitializeComponent(); 
            OpenStreetMapProvider osmProvider = new OpenStreetMapProvider();
            osmProvider.TileDownloader = new CustomTileDownloader(); 
            this.radMap1.Providers.Add(osmProvider);
        }

        public class CustomTileDownloader : MapTileDownloader
        {
            public override void BeginDownloadTile(Uri uri, TileInfo tileInfo)
            {
                lock (this.webClientsPoolLockObject)
                {
                    if (!this.webClientsPool.ContainsKey(tileInfo.Quadkey))
                    {
                        WebClient client = new WebClient();
                         client.Headers[HttpRequestHeader.UserAgent] = "your application name"; 
                        this.webClientsPool.Add(tileInfo.Quadkey, client);
                        this.webRequestCache.Add(tileInfo.Quadkey, uri);
                        client.DownloadDataCompleted += TileDownloadDataCompleted;
                        client.DownloadDataAsync(uri, tileInfo);
                    }
                }
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.