WP Google Maps
Patch: HTTPS Support (2 posts)

  1. Alexander Gieg
    Posted 3 years ago #

    I noticed a small problem with your plugins when a page with a map was loaded via HTTPS in that Google complained the page had insecure items, asking whether to load them or not. Looking at your code I noticed this happens because the JavaScript is loaded directly from "http://maps.google.com/..." at wpGoogleMaps.php lines 213, 315 and 615. I attempted then manually loading it from https://maps.google.com, and it worked, so I figured a simple fix would to do the same thing Google itself does when loading Google Analytics, by changing those three lines from:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>


    <script type="text/javascript">
    	var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
    	document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));

    I tested this on 5.01 and it works perfectly: no more complaints from Google Chrome when loading the page from the HTTPS version!

    I hope this helps. It'd be nice to have this added to the official plugin!

    PS.: Naturally, an even simpler version would be:

    <script type="text/javascript">document.write(unescape("%3Cscript src='" + document.location.protocol + "//maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));</script>


  2. WPGMaps
    Plugin Author

    Posted 3 years ago #

    Thank you so much for this Alexander! I will implement this in v5.02 - MUCH appreciated!

    Kind regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Google Maps
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic