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

Support for Google maps

8 Answers 778 Views
Map
This is a migrated thread and some comments may be shown as answers.
Roman Kurdadze
Top achievements
Rank 1
Roman Kurdadze asked on 01 Mar 2020, 06:24 PM
In example for WPF (https://www.telerik.com/forums/support-for-google-maps) you have a really great article on how to integrate Google or similar xyz imagery providers into RadMap. Is it possible to put the same example here for WinForms (c# project)? Because after hours of internet surfing, I was unable to find any information on this.

8 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 04 Mar 2020, 01:54 PM

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

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.
0
Roman Kurdadze
Top achievements
Rank 1
answered on 09 Mar 2020, 02:15 PM
Some solution is extremely needed - that is one of the main aspect of the component functionality....
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Mar 2020, 11:11 AM

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

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.
0
Roman Kurdadze
Top achievements
Rank 1
answered on 13 Mar 2020, 06:57 PM

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


0
Roman Kurdadze
Top achievements
Rank 1
answered on 13 Mar 2020, 07:31 PM

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!

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Mar 2020, 12:43 PM
Hello, Roman, 

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

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.
0
Roman Kurdadze
Top achievements
Rank 1
answered on 16 Mar 2020, 12:46 PM

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);
                }
            }
        }

    }

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Mar 2020, 09:01 AM
Hello, Roman, 

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

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.
Tags
Map
Asked by
Roman Kurdadze
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Roman Kurdadze
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or