Virtual Earth: SSL Support

Dec 21, 2007  • Mapping

I’ve implemented Virtual Earth within many web applications, but one thing that I’ve only had to do a couple times is run the site under SSL. If you have ever done this, then you know that the web browser doesn’t like this and complains with the “Do you want to display nonsecure items?” prompt. This can be a pain for users, escpecially when they click “No” and then wonder why the map isn’t there.

Is SSL Supported?

Yes, even though it isn’t documented, Virtual Earth does support being referenced under SSL. The reason I know this without it being documented is because David Barkol has blogged about it here. This is the only place I’ve found it mentioned, and it’s not as simple as just using HTTPS.

How to reference Virtual Earth under SSL

To reference Virtual Earth v6 using SSL you must pass “s=1” in the querystring, as well as use HTTPS.

Here’s the full URL to reference Virtual Earth using SSL:

https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6&s=1

Why do we need “s=1”?

You’d think that by just referencing Virtual Earth using HTTPS you’d be all set. Even though you load the VE script using SSL, VE still requests all map images without SSL, thus causing the prompt to still pop up.

By adding “s=1” to the querystring, you are telling VE to load the map images and other stuff it references using SSL. Doing this removes the annoying prompt from coming up, and eliminating any user confusion when they click “No”.

Now, you’re probably wondering the same thing I am, “Why doesn’t VE just see the HTTPS and reference everything accordingly?” Well, I’m not quite sure, but this may be something they change in a future release.