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

OpenStreetMapProvider through https

14 Answers 141 Views
Map
This is a migrated thread and some comments may be shown as answers.
Andi
Top achievements
Rank 1
Andi asked on 27 Dec 2017, 08:59 AM

Hi there,

we are using RadMap with the OpenStreetMapProvider.

Is it possible to get the maps through a secured connection (https).

Our client is not allowed to open http to OpenStreetMap.

I have read that tile serving is possible though ssl.

Thank you,

Andi

14 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 02 Jan 2018, 09:18 AM
Hi Andi,

To download map tiles via https connection, you need to override the URI string which are used for accessing the openstreet maps. You can create custom map provider with custom map sources. Please check out the article and the following code which actually overrides the 4 connection strings used by the OpenStreetProvider:

RadMap Implement Custom Map Provider

  public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
            this.map.Provider = new HttpsOpenStreetProvider();
        }           
    }
 
    public class HttpsOpenStreetProvider : TiledProvider
    {
        /// <summary>
        /// Initializes a new instance of the MyMapProvider class.
        /// </summary>
        public HttpsOpenStreetProvider()
              : base()
        {
            OsmTileMapSource source = new HttpsOpenStreetMapnikSource();
            this.MapSources.Add(source.UniqueId, source);
 
            source = new HttpsOpenStreetCycleSource();
            this.MapSources.Add(source.UniqueId, source);
 
            source = new HttpsOpenStreetCycleTransportSource();
            this.MapSources.Add(source.UniqueId, source);
 
            source = new HttpsOpenStreetHumanitarianSource();
            this.MapSources.Add(source.UniqueId, source);
 
            this.SetupCommands();
        }
        /// <summary>
        /// Returns the SpatialReference for the map provider.
        /// </summary>
        public override ISpatialReference SpatialReference
        {
            get
            {
                return new MercatorProjection();
            }
        }
 
        private void SetupCommands()
        {
            this.CommandBindingCollection.Clear();
 
            string uriString = "/Telerik.Windows.Controls.DataVisualization;component/themes/road.png";
 
            this.RegisterSetSourceCommand(
                typeof(HttpsOpenStreetMapnikSource),
                LocalizationManager.GetString("MapOsmStandardCommand"),
                null,
                new Uri(uriString, UriKind.RelativeOrAbsolute),
                null,
                null);
 
            this.RegisterSetSourceCommand(
                typeof(HttpsOpenStreetCycleSource),
                LocalizationManager.GetString("MapOsmCycleCommand"),
                null,
                new Uri(uriString, UriKind.RelativeOrAbsolute),
                null,
                null);
 
            this.RegisterSetSourceCommand(
                typeof(HttpsOpenStreetCycleTransportSource),
                LocalizationManager.GetString("MapOsmTransportCommand"),
                null,
                new Uri(uriString, UriKind.RelativeOrAbsolute),
                null,
                null);
 
            this.RegisterSetSourceCommand(
                typeof(HttpsOpenStreetHumanitarianSource),
                LocalizationManager.GetString("MapOsmHumanitarianCommand"),
                null,
                new Uri(uriString, UriKind.RelativeOrAbsolute),
                null,
                null);
        }
    }
    public class HttpsOpenStreetMapnikSource : OsmTileMapSource
    {
        public HttpsOpenStreetMapnikSource() : base(@"https://{prefix}.tile.openstreetmap.org/{zoom}/{x}/{y}.png")
        {
        }
    }
 
    public class HttpsOpenStreetCycleSource : OsmTileMapSource
    {
        public HttpsOpenStreetCycleSource() : base(@"http://{prefix}.tile.opencyclemap.org/cycle/{zoom}/{x}/{y}.png")
        {
        }
    }
 
    public class HttpsOpenStreetCycleTransportSource : OsmTileMapSource
    {
        public HttpsOpenStreetCycleTransportSource() : base(@"https://{prefix}.tile2.opencyclemap.org/transport/{zoom}/{x}/{y}.png")
        {
        }
    }
 
    public class HttpsOpenStreetHumanitarianSource : OsmTileMapSource
    {
        public HttpsOpenStreetHumanitarianSource() : base(@"https://{prefix}.tile.openstreetmap.fr/hot/{zoom}/{x}/{y}.png")
        {
        }
    }
}


Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Andi
Top achievements
Rank 1
answered on 12 Jan 2018, 03:07 PM

Hi Petar,

I tried your implementation. Unfortunately it does not work!

All map tiles are still coming through HTTP.

See attached my Fiddler log

Any ideas?

TIA, Andi

0
Petar Mladenov
Telerik team
answered on 17 Jan 2018, 11:01 AM
Hello Andi,

It appears the HTTPS prefix from the URI string is replaced in later stage (when building the URI for download). We changed the solution to replace "http" wiith "https" at the final stage before downloading a specific tile:

public class HttpsOpenStreetCycleSource : OpenStreetCycleSource
   {
       protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
       {
           Uri baseURI = base.GetTile(tileLevel, tilePositionX, tilePositionY);
           string uriString = baseURI.AbsoluteUri.Replace("http", "https");
           return new Uri(uriString);
       }
   }

Please give it a try and let us know how it goes on your side.

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Andi
Top achievements
Rank 1
answered on 18 Jan 2018, 05:15 PM

Thank you Petar this solution worked for us! 

I also had to change our web app - where we also used RadMap:

string urlTemplate;
urlTemplate = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png";
 
var mapLayer = new MapLayer { Type = LayerType.Tile, UrlTemplate = urlTemplate };
WebControl.LayersCollection.Add(mapLayer);
 
var bubbleLayer = new MapLayer { Type = LayerType.Bubble, LocationField = "Location", ValueField = "Value" };
radMap.LayersCollection.Add(bubbleLayer);
0
Davide
Top achievements
Rank 1
answered on 06 Jun 2019, 01:01 PM

Hi all. it is a couple of days that I am having problems in retrieving the tile from the OpenStreetProvider via https connection.

I'm getting the following message for each tile request I do:  "429 Too Many Requests"

No problem if I use a http connection.

Does someone know the reason?

Tnx in advance

 

Davide

0
Petar Mladenov
Telerik team
answered on 11 Jun 2019, 09:20 AM
Hello Davide,

I reproduced this "429" error but we are still not sure regarding its root cause. I submitted a question in OpenStreetMap forum:

https://help.openstreetmap.org/questions/69578/429-too-many-requests-when-using-https-atileopenstreetmaporgxyz

Also I tested this in our Kendo UI map:
https://dojo.telerik.com/AxiZezUf
Map works fine with HTTPs but I guess this is routed from other IP address.

Can you share more details regarding your WPF and Web maps - do you experience difference in them or they both started failing in the same day ?

Regards,
Petar Mladenov
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
Davide
Top achievements
Rank 1
answered on 11 Jun 2019, 10:16 AM

Hi Petar, 

thx for the responce.

 

I saw that the question you submitted to OpenstreetMap has been closed as:

"The question has been closed for the following reason "Duplicate Question" by Frederik Ramm 44 mins ago".

 

Digging inside the forum i found the following page: "https://operations.osmfoundation.org/policies/nominatim/"

From some testing it looks like that if the request has the "UserAgent" header filled the GET request has a response.

 

Hope this can help in finding a solution.

 

Davide

 

0
Petar Mladenov
Telerik team
answered on 11 Jun 2019, 10:25 AM
Hi Davide,

Apparently, I have submitted 2 posts while waiting for my registration completes. Here is the open thread:

https://help.openstreetmap.org/questions/69579/too-many-requests-when-using-https-atileopenstreet-and-no-issues-when-using-http-atileopenstreet

Can you send me the post you have read regarding the UserAgent header ?

Regards,
Petar Mladenov
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
Davide
Top achievements
Rank 1
answered on 11 Jun 2019, 11:46 AM

The page is:

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

 

Requirements
- No heavy uses (an absolute maximum of 1 request per second).
- Provide a valid HTTP Referer or User-Agent identifying the application (stock User-Agents as set by http libraries will not do).
- Clearly display attribution as suitable for your medium.
- Data is provided under the ODbL license which requires to share alike (although small extractions are likely to be covered by fair usage / fair dealing).

 

I added the user-agent header and got a OK response

 

 

Davide

 

0
Davide
Top achievements
Rank 1
answered on 11 Jun 2019, 03:32 PM

This article could be useful too:

https://help.openstreetmap.org/questions/55828/overpass-returns-429-every-time-for-some-queries-but-not-for-others

 

Davide

0
Dilyan Traykov
Telerik team
answered on 11 Jun 2019, 04:05 PM
Hello Davide,

Thank you very much for the provided resources.

Indeed, it seems that specifying a non-stock user agent for the request correctly downloads the tiles via https.

Thus, we plan to introduce a new WebHeaders property of the MultiScaleTileSource (from which the OpenStreetMapnikSource inherits) through which you can add any headers you require (such as User-Agent and Referrer). You will then be able to set the user-agent of the requests like so:

public class HttpsOpenStreetProvider : TiledProvider
    {
        /// <summary>
        /// Initializes a new instance of the MyMapProvider class.
        /// </summary>
        public HttpsOpenStreetProvider()
              : base()
        {
            OsmTileMapSource source = new HttpsOpenStreetMapnikSource();
            source.WebHeaders.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0");
            this.MapSources.Add(source.UniqueId, source);
        }
}

This property will be available with our Service Pack which will be introduced in the middle of next week.

Please let us know whether you would find this new property helpful.

Regards,
Dilyan Traykov
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
Andi
Top achievements
Rank 1
answered on 26 Jul 2019, 06:23 AM

Hi Dilyan,

is this Fix released? We installed the latest version and the property WebHeaders is NOT defined.
We have to release our product with https map support and we can't due to this failure.

Please tell us where to get the fix or service pack.

TIA, Andi

0
Accepted
Dilyan Traykov
Telerik team
answered on 26 Jul 2019, 02:56 PM
Hi Andi,

The WebHeaders property of the MultiScaleTileSource class was officially introduced with the 2019.2.618 version of our controls. The release notes for this service pack can be found here.

Can you please confirm that you're using this or a newer version of the suite? If this is the case, please provide a small sample project or code snippet of your setup so that I can further investigate and assist you.

Regards,
Dilyan Traykov
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
Andi
Top achievements
Rank 1
answered on 30 Jul 2019, 06:52 AM

Hi Dilyan,
you are right - with the new version the propertys WebHeaders exists and all works fine.

Thank you,

Andi


Tags
Map
Asked by
Andi
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Andi
Top achievements
Rank 1
Davide
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or