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