RadMap => Map OK in local but not in another PC

0 Answers 141 Views
Map
Thierry
Top achievements
Rank 1
Thierry asked on 11 Aug 2021, 11:50 PM

Hello to the team,

 

This is my problem :

I have a screen with rapMap (which represents World) in my local PC, with 2 labels representing a travel between country A and country B.

When I run my application on another PC than mine, the background of the map disappears (the labels are OK).

 

What could I do to solve this problem ? 

 

Thanks a lot for advance,

Thierry 

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 12 Aug 2021, 11:09 AM

Hi, Thierry,

According to the provided information, it is not clear how RadMap is setup in your project, what is the used provider, how the two labels are added, etc. Could you please elaborate? It would be greatly appreciated if you can share a sample code snippet demonstrating how to reproduce the issue you are facing. Thus, we would be able to give it a try on our end and provide further assistance. Thank you in advance.

I am looking forward to your reply.

Thierry
Top achievements
Rank 1
commented on 12 Aug 2021, 06:05 PM

Hello Dess,

 

Thank you for your answer.

 

I use then OpenStreetMapProvider. Here is my code :

SetupProviders_ProgrammeTournois()
            frmMap.RadMap1.Layers.Clear()
            Dim pathLayer As New MapLayer("Path")
            Dim pinsLayer As New MapLayer("Pins")
            frmMap.RadMap1.Layers.Add(pathLayer)
            frmMap.RadMap1.Layers.Add(pinsLayer)
            Dim pin As New MapPin(New PointG(W_LatitudeDepart, W_LongitudeDepart))
            pin.IsVisible = True
            pin.BackColor = Color.FromArgb(11, 195, 197)
            pin.BorderDashStyle = Drawing2D.DashStyle.DashDot
            pin.ForeColor = Color.AliceBlue
            pin.GradientAngle = 45
            pin.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
            pin.ToolTipText = VilleActuelle
            pin.Text = VilleActuelle
            frmMap.RadMap1.Layers("Pins").Add(pin)
            Dim pinLabel As MapLabel = New MapLabel(New PointG(W_LatitudeDepart, W_LongitudeDepart), VilleActuelle) With {.BackColor = Color.DimGray}
            pinLabel.ForeColor = Color.White
            pinLabel.Size = New Size(3, 3)
            pinLabel.Font = New Font("Arial", 7.0F, FontStyle.Bold)
            frmMap.RadMap1.Layers("Pins").Add(pinLabel)
            Dim pin2 As New MapPin(New PointG(W_LatitudeArrivee, W_LongitudeArrivee))
            pin2.IsVisible = True
            pin2.BackColor = Color.FromArgb(11, 195, 197)
            pin2.BorderDashStyle = Drawing2D.DashStyle.DashDot
            pin2.ForeColor = Color.AliceBlue
            pin2.GradientAngle = 45
            pin2.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
            pin2.ToolTipText = VilleArrivee
            pin2.Text = VilleArrivee
            frmMap.RadMap1.Layers("Pins").Add(pin2)
            Dim pinLabel2 As MapLabel = New MapLabel(New PointG(W_LatitudeArrivee, W_LongitudeArrivee), VilleArrivee) With {.BackColor = Color.DimGray}
            pinLabel2.ForeColor = Color.White
            pinLabel2.Size = New Size(3, 3)
            pinLabel2.Font = New Font("Arial", 7.0F, FontStyle.Bold)
            frmMap.RadMap1.Layers("Pins").Add(pinLabel2)

            frmMap.RadMap1.Layers("Path").Add(Creer_Trajet(New PointG(W_LatitudeDepart, W_LongitudeDepart), New PointG(W_LatitudeArrivee, W_LongitudeArrivee)))
            frmMap.ShowDialog()

 

And this is the code of the Sub SetupProviders_ProgrammeTournois :

Public Sub SetupProviders_ProgrammeTournois()
        Dim cacheFolder As String = "..\..\cache"
        Dim osmProvider As New OpenStreetMapProvider()
        Dim cache As New LocalFileCacheProvider(cacheFolder)
        osmProvider.CacheProvider = cache
        frmMap.RadMap1.MapElement.Providers.Add(osmProvider)

    End Sub

 

In Attached files, the screen Capture on development PC.png shows the map on my PC, so the Development PC.

The screen Capture on client PC.png shows the map on a client PC. The backround of the map with the countries is not visible.

 

Thanks a lot for your help.

Thierry 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 13 Aug 2021, 11:16 AM

Hello, Thierry,

Indeed, the provided screenshots illustrate that the second computer doesn't load the map tiles. I have noticed that the provider is not properly setup as it is demonstrated in the following help article: 

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

Dim cacheFolder As String = "..\..\cache"
Dim osmProvider As New OpenStreetMapProvider()
Dim tileDownloader As MapTileDownloader = TryCast(osmProvider.TileDownloader, MapTileDownloader)
tileDownloader.WebHeaders.Add(System.Net.HttpRequestHeader.UserAgent, "your application name")
Dim cache As New LocalFileCacheProvider(cacheFolder)
osmProvider.CacheProvider = cache
Me.radMap1.MapElement.Providers.Add(osmProvider)

Please make sure that the second machine has a stable internet connection and the HttpRequestHeader.UserAgent is specified.

 

Thierry
Top achievements
Rank 1
commented on 13 Aug 2021, 01:33 PM

Hello Dess,

 

Thank you for the answer.

The second machine has a stable internet connection.

 

When I add this line :

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

I have a syntax error message, as you can see in the attached file. It tells that WebHeaders is not a member of Telerik.WinControls.UI.MapTileDownLoader.

Should I add a reference ?

 

Thanks a lot,

Thierry 

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 13 Aug 2021, 01:51 PM

Hi, Thierry,

As of  R1 2020 you must specify the User Agent. If you don't have access to it in the MapTileDownloader, I suppose that you are using an older version. That is why I would kindly ask you to upgrade in order to benefit from the introduced improvement for the OpenStreetMapProvider. This is the public feedback item related to these changes: 

https://feedback.telerik.com/winforms/1448367-radmap-openstreetmap-provider-does-not-follow-the-latest-openstreetmap-tile-usage-policy-requiring-useragent-header 

Thierry
Top achievements
Rank 1
commented on 13 Aug 2021, 04:31 PM

Hello Dess,

 

Thank you for your prompt reply.

I checked the link you sent me, would you have the code in VB.NET ?

I still have syntax errors about webClientsPool.

What do you mean by 'upgrade' ? Is it a change of the radMap.dll ?


Dim client As New WebClient()    => correct line
 client.Headers(HttpRequestHeader.UserAgent) = "your application name"     => correct line
client.webClientsPool.Add(TileInfo.Quadkey, client)     => UNCORRECT line (webClientsPool)
this.webRequestCache.Add(TileInfo.Quadkey, Uri)        => UNCORRECT line (I don't know how to interprete 'this' in VB.NET
client.DownloadDataCompleted += TileDownloadDataCompleted        => UNCORRECT line
client.DownloadDataAsync(Uri, TileInfo)        => UNCORRECT line

Sincerely,

Thierry 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 16 Aug 2021, 04:39 AM

Hi, Thierry,

Please refer to the below screenshot illustrating how you can switch from C# to VB.NET the code snippet in the online documentation:

By "upgrading", I mean changing the Telerik assemblies to a newer version than R1 2020:

https://docs.telerik.com/devtools/winforms/installation-and-upgrades/updating-assemblies-in-a-project 

No answers yet. Maybe you can help?

Tags
Map
Asked by
Thierry
Top achievements
Rank 1
Share this question
or