Thursday, July 1, 2010

Bing Ajax Control over HTTPS or HTTP Secure

So I have not updated in awhile, why you ask? Because I have been neck deep for months on 5 large projects and one of them has been “Geo Mapping”.


So recently I was integrating the project into the main portal site, which runs under HTTPS. We are using the Bing API  and all I had to do was flip the URL to the Bing control from HTTP to HTTPS.

Woops, wrong there. Not entirely anyhow everything worked except that the map tiles were being pulled from HTTP still. So after hunting about for a day I found an undocumented parameter, well no documentation that I could locate.

So here are the two ways to add the Bing Ajax control to your page in HTTP or HTTPS:


<script src=”” type="text/javascript"></script>


<script src=”” type="text/javascript"></script>

Now on the HTTPS version notice I changed the URL to start with HTTPS, this is what pulls from the secure site over at the good Bing folks. Also notice I added the “s” parameter and set it to 1, default is 0, this tells the Bing API to get the image tiles for the map from HTTPS.

Why? you ask.

Well it seems that the API determines what protocol to use for JavaScript and other parts from the document.location.protocol, however when it comes to the map tiles it looks to a global setting that is set based on the parameter being passed.


Well we all make mistakes but at least I found a solution. And I hope that anyone else that runs into it will find this post. Enjoy!

1 comment:

Anonymous said...

Thanks for the reference here. We have a product that uses the reference at

The use of Bing was legacy from when we made the module some time ago. It is interesting how little information there is in the use of HTTPS reference for this code.

You saved us some time, thanks.