RadMap not working

1 Answer 202 Views
Form General Discussions Map
Chris
Top achievements
Rank 1
Chris asked on 20 Dec 2022, 05:18 PM
As of the beginning of December, the RadMap is failing to get maps from the BingRestMapProvider and the OpenStreetMapProvider. When registering the provider the connection is getting forcibly closed on the server side. Has something changed? Is there an ETA on when the server side issue will get resolved?

1 Answer, 1 is accepted

Sort by
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Dec 2022, 05:49 AM

Hello, Chris,

This is the first report for any unexpected behavior regarding RadMap so far. We haven't had similar reports from other customers. However, according to the provided information, it wouldn't be easy to determine what causes this unexpected behavior on your end. Could you please elaborate? It would be greatly appreciated if you can give us more details about the exact setup that you have.

The following help articles demonstrate how to properly setup both providers, OpenStreetMapProvider and BingRestMapProvider:

https://docs.telerik.com/devtools/winforms/controls/map/providers/openstreetmapprovider 

https://docs.telerik.com/devtools/winforms/controls/map/providers/bingmaps/bingrestmapprovider 

Please make sure that you use a similar approach. Thank you in advance for sharing the code for the map's initialization. I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Chris
Top achievements
Rank 1
commented on 21 Dec 2022, 03:10 PM

Using Telerik.WinControls.RadMap version 2019.1.219.40 (Runtime Version V4.0.30319)

This has been working in our application for many years and just recently stopped working.

Below is the code we use to set up the map as well as notificdations. When setting up the BingMap, we get an Initialization Error. When we set up the OsmProvider, we get the Initialization Complete event, but still no maps. 

Again, let me stress this is part of an existing application that has been around for years and nothing has changed in the code. And we have validated that are last release from earlier this year is also having the same issues now.


    private void SetupProviders() {
      try {
        isReady = false;
        while(radMap1.MapElement.Providers.Count() > 0)
          radMap1.MapElement.Providers.Remove(radMap1.MapElement.Providers[0]);

        if(radMap1.MapElement.Providers.Count == 0) {
          if(mapType == MapType.OpenStreetMap) {
            string cacheFolder = System.IO.Path.Combine(Application.LocalUserAppDataPath, "Cache");
            if(!System.IO.Directory.Exists(cacheFolder)) {
              System.IO.Directory.CreateDirectory(cacheFolder);
            }
            OpenStreetMapProvider osmProvider = new OpenStreetMapProvider();
            //MapTileDownloader tileDownloader = osmProvider.TileDownloader as MapTileDownloader;
            //tileDownloader.WebHeaders.Add(System.Net.HttpRequestHeader.UserAgent, "Control Center");
            LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
            osmProvider.CacheProvider = cache;
            osmProvider.InitializationComplete += OsmProvider_InitializationComplete;
            this.radMap1.MapElement.Providers.Add(osmProvider);
          } else if(mapType == MapType.BingAerial || mapType == MapType.BingAerialWithLabels || mapType == MapType.BingCanvasDark || mapType == MapType.BingCanvasGray || mapType == MapType.BingCanvasLight || mapType == MapType.BingRoad) {
            BingRestMapProvider bingMap = new BingRestMapProvider();
            bingMap.BingKey = "XXX Our Key XXX";
            bingMap.UseSession = true;
            if(mapType == MapType.BingAerial)
              bingMap.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.Aerial;
            else if(mapType == MapType.BingAerialWithLabels)
              bingMap.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.AerialWithLabels;
            else if(mapType == MapType.BingCanvasDark)
              bingMap.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.CanvasDark;
            else if(mapType == MapType.BingCanvasGray)
              bingMap.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.CanvasGray;
            else if(mapType == MapType.BingCanvasLight)
              bingMap.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.CanvasLight;
            else if(mapType == MapType.BingRoad)
              bingMap.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.Road;
            bingMap.InitializationComplete += BingMap_InitializationComplete;
            bingMap.InitializationError += BingMap_InitializationError;
            this.radMap1.MapElement.Providers.Add(bingMap);
          }
        }
      }catch(Exception ex) {
        ErrorLog.NewError(ex, "MapWindow_SetupProviders", "Unable to setup map providers", ErrorLog.ErrorSeverity.Medium);
      }
    }

    private void BingMap_InitializationError(object sender, EventArgs e)
    {
      Type t = e.GetType();
      string args = e.ToString();
      System.Diagnostics.Debug.WriteLine("Bing Map Initiation Error: {0}", "Failed to connect");
    }

    private void BingMap_InitializationComplete(object sender, EventArgs e) {
      isReady = true;
    }

    private void OsmProvider_InitializationComplete(object sender, System.EventArgs e) {
      isReady = true;
    }
Dess | Tech Support Engineer, Principal
Telerik team
commented on 22 Dec 2022, 07:55 AM

Hello, Chris,   

According to the provided code snippet, it seems that the WebHeaders part is commented. However, it is required as it is demonstrated in the previously referred help article: https://docs.telerik.com/devtools/winforms/controls/map/providers/openstreetmapprovider 

We had similar reports for an empty RadMap in the past. Our control was affected because OpenStreetMap changed their tile usage policy and require UserAgent string in the web headers for accessing tile.openstreetmap.org tiles. Here is the public feedback item for your reference:
https://feedback.telerik.com/winforms/1448367-radmap-openstreetmap-provider-does-not-follow-the-latest-openstreetmap-tile-usage-policy-requiring-useragent-header 

Please make sure that the setup the provider according our online documentation and let me know how it works on your end.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 
Chris
Top achievements
Rank 1
commented on 22 Dec 2022, 04:18 PM

The commented code for the MapTileDownloader was an attempt to follow the examples when I first started debugging the code. The reason why it is commented out is because MapTileDownloader does not contain a definition for WebHeaders. Perhaps it is defined in a later version of the tools, but it does not seem to be part of the version we are using. 

The code had been working without those two lines of code up until the beginning of this month. 

Chris
Top achievements
Rank 1
commented on 22 Dec 2022, 04:34 PM | edited

I was able to get the OpenStreetMapProvider to work with the custom Tile Downloader workaround suggested in the thread talking about the usage policy requiring a user agent header.

 

While that work around worked for the OpenStreetMapProvider, it did not work for the BingRestMapProvider.

 

Any suggestions on how to get the Bing maps working again?

Chris
Top achievements
Rank 1
commented on 22 Dec 2022, 04:43 PM | edited

FYI, I added the additional lines of initialization code for the Bing Maps and it is still getting an error when initializing, so the initialization process now looks like:

BingRestMapProvider bingMap = new BingRestMapProvider();
bingMap.UseSession = true;
bingMap.BingKey = "Our Key";
string cacheFolder = System.IO.Path.Combine(Application.LocalUserAppDataPath, "Cache");
LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
bingMap.CacheProvider = cache;
this.radMap1.MapElement.Providers.Add(bingMap);
Dess | Tech Support Engineer, Principal
Telerik team
commented on 23 Dec 2022, 10:32 AM

Hello, Chris,   

Indeed, the MapTileDownloader did not contain a definition for WebHeaders in the old version when the OpenStreetMapProvider introduced the changes. It requires applying the suggested workaround in the previous feedback item. A better option is to upgrade to the latest version in order to benefit from the fix.

As to the BingRestMapProvider,  after further testing and researching, it seems that Microsoft has restricted the TLS protocol. Since BingRestMapProvider requires TLS 1.2 coming automatically with .NET Framework 4.7, it is necessary to specify the version explicitly: 

        public RadForm1()
        {
            InitializeComponent();
            string bingKey = "your Bing key";

            // How to specify Tls 1.2 for .NET Framework 4.0
            //System.Net.ServicePointManager.SecurityProtocol =(System.Net.SecurityProtocolType)3072;

            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
            string cacheFolder = @"..\..\cache";
            BingRestMapProvider bingProvider = new Telerik.WinControls.UI.BingRestMapProvider();
            bingProvider.InitializationError += bingProvider_InitializationError;
            bingProvider.Culture = System.Threading.Thread.CurrentThread.CurrentCulture;
            bingProvider.UseSession = true;
            bingProvider.BingKey = bingKey;
            LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
            bingProvider.CacheProvider = cache;
            this.radMap1.Providers.Add(bingProvider);
        }

        private void bingProvider_InitializationError(object sender, InitializationErrorEventArgs e)
        {
          //TODO
        }

 

More information is available here:  Transport Layer Security (TLS) best practices with the .NET Framework

Please give this approach a try and see how it works on your end.

Chris
Top achievements
Rank 1
commented on 23 Dec 2022, 02:57 PM

Thank you so much. Everything is back up and running like it was before.

 

I really appreciate all of your help and time in getting this resolved.

Tags
Form General Discussions Map
Asked by
Chris
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or