OpenStreetMapProvider through https

15 posts, 1 answers
  1. Andi
    Andi avatar
    16 posts
    Member since:
    Dec 2012

    Posted 27 Dec 2017 Link to this post

    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

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3100 posts

    Posted 02 Jan 2018 Link to this post

    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.
  3. Andi
    Andi avatar
    16 posts
    Member since:
    Dec 2012

    Posted 12 Jan 2018 in reply to Petar Mladenov Link to this post

    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

  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3100 posts

    Posted 17 Jan 2018 Link to this post

    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.
  5. Andi
    Andi avatar
    16 posts
    Member since:
    Dec 2012

    Posted 18 Jan 2018 in reply to Petar Mladenov Link to this post

    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);
  6. Davide
    Davide avatar
    5 posts
    Member since:
    Aug 2015

    Posted 06 Jun Link to this post

    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

  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3100 posts

    Posted 11 Jun Link to this post

    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.
  8. Davide
    Davide avatar
    5 posts
    Member since:
    Aug 2015

    Posted 11 Jun in reply to Petar Mladenov Link to this post

    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

     

  9. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3100 posts

    Posted 11 Jun Link to this post

    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.
  10. Davide
    Davide avatar
    5 posts
    Member since:
    Aug 2015

    Posted 11 Jun in reply to Petar Mladenov Link to this post

    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

     

  11. Davide
    Davide avatar
    5 posts
    Member since:
    Aug 2015

    Posted 11 Jun in reply to Davide Link to this post

    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

  12. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1031 posts

    Posted 11 Jun Link to this post

    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.
  13. Andi
    Andi avatar
    16 posts
    Member since:
    Dec 2012

    Posted 26 Jul in reply to Dilyan Traykov Link to this post

    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

  14. Answer
    Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1031 posts

    Posted 26 Jul Link to this post

    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.
  15. Andi
    Andi avatar
    16 posts
    Member since:
    Dec 2012

    Posted 30 Jul in reply to Dilyan Traykov Link to this post

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

    Thank you,

    Andi


Back to Top