8 Answers, 1 is accepted
Hi Roman,
The approach suggested in the WPF forum is not suitable for the WinForms RadMap control. First we need to research if a similar solution would be possible in WinForms and if it is we might create a KB article. At the moment I cannot give a time estimate when this will happen. You can keep an eye on our KB page here: https://docs.telerik.com/devtools/winforms/knowledge-base. I hope for the time being that using the WPF control is an option.
Regards,
Hristo
Progress Telerik
Hello, Roman,
RadMap does not have a Google Maps provider and currently such cannot be implemented because of the additional protection which Google implemented in their service. Using the Google Maps tile server in a WinForms application is not allowed. Currently, we do not plan to implement support for Google map API.
Note that the RadMap control in Tеlerik UI for WPF has a different internal implementation compared to the RadMap in WinForms.
However, in case that your customer has a license for using Google API, I have invested some time to adopt the Google Maps solution for the WinForms map. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best.
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Thanks a lot for such prompt reply and taking care to find a solution, really appreciated.
The problem with project is that it cannot be compiled due to error:
'Telerik.WinControls.UI.MapTileDownloader' does not contain a definition for 'WebHeaders' and no extension method 'WebHeaders' accepting a first argument of type 'Telerik.WinControls.UI.MapTileDownloader' could be found (are you missing a using directive or an assembly reference?)
RadForm1.cs50281455925MapGoogleProvider
Finally it WORKS! I wrote custom provider which has implementation on WebHeaders and thats it!
Thanks once again - i bet that TELERIK support is best of the best - respect!
Note that the WebHeaders property of the MapTileDownloader was introduced in R1 2020 along with addressing the following item: 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 you use at least this version when using this custom implementation for RadMap.
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Here is solution i came up with:
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] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0";
this.webClientsPool.Add(tileInfo.Quadkey, client);
this.webRequestCache.Add(tileInfo.Quadkey, uri);
client.DownloadDataCompleted += TileDownloadDataCompleted;
client.DownloadDataAsync(uri, tileInfo);
}
}
}
}
This approach is also a valid one. However, if you use the latest version of the Telerik UI for WinForms suite, you don't need to create a derivative of the MapTileDownloader class since we have exposed a public WebHeaders property.
However, feel free to use this approach which suits your custom requirement best.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik