Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 如何使用Google Maps Marker Clusterer Plus避免混合内容警告_Google Maps_Https_Google Maps Markers_Markerclusterer - Fatal编程技术网

Google maps 如何使用Google Maps Marker Clusterer Plus避免混合内容警告

Google maps 如何使用Google Maps Marker Clusterer Plus避免混合内容警告,google-maps,https,google-maps-markers,markerclusterer,Google Maps,Https,Google Maps Markers,Markerclusterer,当您的网站通过HTTPS加载时,Google Maps Marker Clusterer和默认图标仍然通过普通HTTP加载 这会触发大多数浏览器的“混合内容”警告 只需添加以下行: MarkerClusterer.IMAGE_PATH = "https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m"; 在调用Google Maps Marker Clusterer P

当您的网站通过HTTPS加载时,Google Maps Marker Clusterer和默认图标仍然通过普通HTTP加载

这会触发大多数浏览器的“混合内容”警告

只需添加以下行:

MarkerClusterer.IMAGE_PATH = "https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m";
在调用Google Maps Marker Clusterer Plus之前:

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

您还可以通过在实例化MarkerClusterer时指定imagePath选项(如下所示),以类似的方式解决此问题:

更新:不久前,Google代码版本已经停止使用,您应该使用以下脚本URL之一(标准和打包版本)来使用新的GitHub托管版本:

实例化MarkerClusterer时,还需要将imagePath选项指向新的托管位置,如下所示:

var mc = new MarkerClusterer(map, markers, { 
    imagePath: 'https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerclustererplus/images/m' 
});
在生产环境中,应使用上述URL(带有cdn前缀)。但是,请记住,作为一项免费服务,它提供

访问Git托管的文件将在以下答案中详细介绍:


为了方便起见,我更新了我的答案,加入了谷歌停用MarkerclusterPlus脚本的谷歌代码副本的详细信息。谢谢你的回答和更新-代码不应该再依赖谷歌代码,因为我完全同意这一点,尽管似乎有不少开发人员在这个问题上被抓住了——主要是因为谷歌地图实用程序库提供的示例只引用了(并且仍然引用)谷歌代码版本
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
var mc = new MarkerClusterer(map, markers, { 
    imagePath: 'https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerclustererplus/images/m' 
});