OpenStreetMapProvider through https

3 posts, 0 answers
  1. Andi
    Andi avatar
    13 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
    3002 posts

    Posted 02 Jan 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
    13 posts
    Member since:
    Dec 2012

    Posted 4 days and 10 hours ago 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

Back to Top