Bing Map Provider Through Https - Unable to Override Imagery Metadata Call

1 Answer 68 Views
Map
Cole
Top achievements
Rank 1
Cole asked on 01 Feb 2022, 01:23 AM

Hello, 

We are needing to retrieve all map tiles for both Bing and Open Street over https instead of http. Using this forum post we were able to successfully retrieve Open Street tiles over https.

https://www.telerik.com/forums/openstreetmapprovider-through-https#1146262

However after structuring the Bing requests similarly, it appears the initialization of the Bing map service will only go out over http. With only https allowed through the firewall, this call fails and the tiles are never retrieved. If we open http, then the initialization is successful, and the map tiles will come through over https. 

This is an example of the Bing endpoint that is only requested over http while launching the map. 

Is there a way to override the initialization or imagery setup with Bing, to have all the mapping calls use https, similar to the GetTile override? 

Example Code In Use:

namespace Map.RadMap
{
    public class CustomHttpsMapProvider : TiledProvider
    {
        public CustomHttpsMapProvider(MapMode mapMode = MapMode.Road, bool hasLabels = false, string applicationId = Strings.BING_MAPS_KEY, string osmUserAgent = null)
              : base()
        {
            // Open Street
            if (osmUserAgent != null)
            {
                OsmTileMapSource source = new HttpsOpenStreetMapSource();
                source.WebHeaders.Add(HttpRequestHeader.UserAgent, osmUserAgent);
                this.MapSources.Add(source.UniqueId, source);
                return;
            }

            // Bing Hybrid, Aerial or Road
            switch (mapMode)
            {
                case MapMode.Aerial:
                    {
                        if (hasLabels)
                        {
                            BingRestAerialLabelSource source = new HttpsBingAerialLabelSource(applicationId);
                            MapSources.Add(source.UniqueId, source);
                        }
                        else
                        {
                            BingRestAerialSource source = new HttpsBingAerialSource(applicationId);
                            MapSources.Add(source.UniqueId, source);
                        }
                        break;
                    }

                case MapMode.Road:
                    {
                        BingRestRoadSource source = new HttpsBingRoadSource(applicationId);
                        MapSources.Add(source.UniqueId, source);
                        break;
                    }
            }
        }

        public override ISpatialReference SpatialReference
        {
            get
            {
                return new MercatorProjection();
            }
        }
    }

    public class HttpsBingAerialSource : BingRestAerialSource
    {
        public HttpsBingAerialSource(string applicationId) : base(applicationId)
        {
        }

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

    public class HttpsBingAerialLabelSource : BingRestAerialLabelSource
    {
        public HttpsBingAerialLabelSource(string applicationId) : base(applicationId)
        {
        }

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

    public class HttpsBingRoadSource : BingRestRoadSource
    {
        public HttpsBingRoadSource(string applicationId) : base(applicationId)
        {
        }

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

    public class HttpsOpenStreetMapSource : OsmTileMapSource
    {
        public HttpsOpenStreetMapSource() : base(@"https://{prefix}.tile.openstreetmap.org/{zoom}/{x}/{y}.png")
        {
        }

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

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 03 Feb 2022, 04:46 PM

Hello Cole,

Upon further investigating this scenario, it appears that a getter from a helper class, that we internally use in the RadMap's implementation, returns this string - "http", and thus, the observed unwanted behavior is present. As a result of this, I have logged a new feature request in our feedback portal, so, what I could suggest is to vote for it, as well as follow it to get notified via e-mail when its status gets changed.

I have tried to change the value via reflection, however, I was unsuccessful.

With that said, I hope the provided information is of help to you. If you need any further help, do not hesitate to let me know.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Cole
Top achievements
Rank 1
commented on 03 Feb 2022, 06:32 PM

Thank you Stenly, I have voted and followed that request. 

It would be nice if the "https" functionality could be built in for all map providers and prevent the need for custom providers.

Stenly
Telerik team
commented on 08 Feb 2022, 03:34 PM

Hello Cole,

The feature request, which is shared in my previous reply, will currently work for the BingMap and OpenStreetMap providers. In addition, this functionality is still in development, and certain issues may arise, however, the developers' team will do their best to make this applicable to the rest of the providers that the RadMap control supports.

 

Tags
Map
Asked by
Cole
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or