Anthony Dahanne
Anthony Dahanne

Reputation: 5033

How to avoid mixed content warnings with Google Maps Marker Clusterer Plus

When your website is loaded through HTTPS, the Google Maps Marker Clusterer Plus default icons are still loaded via plain HTTP

And that triggers the "mixed content" warning from most browsers

some resources were loaded with plain http

Upvotes: 1

Views: 1087

Answers (2)

Chris Cook
Chris Cook

Reputation: 2841

You can also address this, in a similar fashion to Anthony's answer, by specifying the imagePath option when instantiating your MarkerClusterer (as follows):

var mc = new MarkerClusterer(map, markers, { 
    imagePath: 'https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m' 
});

UPDATE: As Google moved the MarkerClustererPlus source over to GitHub a while back, and the Google Code versions have now been discontinued, you should use the new GitHub hosted versions by using one of the following script urls (standard and packed versions):

https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerclustererplus/src/markerclusterer.js
https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerclustererplus/src/markerclusterer_packed.js

You'll also need to direct the imagePath option to the new hosting location when instantiating your MarkerClusterer as follows:

var mc = new MarkerClusterer(map, markers, { 
    imagePath: 'https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerclustererplus/images/m' 
});

In production, the above urls (with the cdn prefix) should be used as they have no traffic limits or throttling and the files are served via a super fast global CDN. However please bear in mind that, as a free service, it offers no uptime or support guarantees.

Accessing files hosted from Git is covered in more detail in the following SO answer:

Link and execute external JavaScript file hosted on GitHub

Upvotes: 1

Anthony Dahanne
Anthony Dahanne

Reputation: 5033

Simply add this line :

MarkerClusterer.IMAGE_PATH = "https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m";

before calling your Google Maps Marker Clusterer Plus :

var markerCluster = new MarkerClusterer(map, allMarkersArray, mcOptions);

Upvotes: 1

Related Questions