使用 Google 地图的混合内容
Mixed Content using Google Maps
我在我的网站中使用 gmaps 显示地图。
我的代码
<div class="col-md-12" >
<script type="text/javascript" content="zk.googleAPIkey='***MyKey***'" />
<gmaps id="gmaps" zoom="${initialZoom}" lat="${initialLatitude}" lng="${initialLongitude}" width="100%" height="350px" showSmallCtrl="false" >
<gmarker id="marker" content="" visible="${false}" />
</gmaps>
</div>
在我的本地服务器中工作正常但在我的生产服务器中使用 https 不工作并且我有这个错误:
异常
zk.wpd:20 Mixed Content: The page at 'https://www.domain.com/' was loaded over HTTPS, but requested an insecure script 'http://www.google.com/jsapi?key=***MyKey***'. This request has been blocked; the content must be served over HTTPS.loadScript @ zk.wpd:20
<gmaps version="3.26" id="gmaps" width="520px" height="400px" showSmallCtrl="true" protocol="https">
您可以尝试添加协议 属性 吗?
我解决了我的问题 zk.googleAPIkey=****key***
https://maps.googleapis.com/maps/api/js?key=****key***
问题是这个标签 zk.googleAPIkey
因为你的值是 http://maps.googleapis.com/maps/api/js?
问题是 http
之前
<script type="text/javascript" content="zk.googleAPIkey='***MyKey***'" />
之后
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=***key***" />
添加了以下内容并解决了我的问题
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"/>
在头
我在我的网站中使用 gmaps 显示地图。
我的代码
<div class="col-md-12" >
<script type="text/javascript" content="zk.googleAPIkey='***MyKey***'" />
<gmaps id="gmaps" zoom="${initialZoom}" lat="${initialLatitude}" lng="${initialLongitude}" width="100%" height="350px" showSmallCtrl="false" >
<gmarker id="marker" content="" visible="${false}" />
</gmaps>
</div>
在我的本地服务器中工作正常但在我的生产服务器中使用 https 不工作并且我有这个错误:
异常
zk.wpd:20 Mixed Content: The page at 'https://www.domain.com/' was loaded over HTTPS, but requested an insecure script 'http://www.google.com/jsapi?key=***MyKey***'. This request has been blocked; the content must be served over HTTPS.loadScript @ zk.wpd:20
<gmaps version="3.26" id="gmaps" width="520px" height="400px" showSmallCtrl="true" protocol="https">
您可以尝试添加协议 属性 吗?
我解决了我的问题 zk.googleAPIkey=****key***
https://maps.googleapis.com/maps/api/js?key=****key***
问题是这个标签 zk.googleAPIkey
因为你的值是 http://maps.googleapis.com/maps/api/js?
问题是 http
之前
<script type="text/javascript" content="zk.googleAPIkey='***MyKey***'" />
之后
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=***key***" />
添加了以下内容并解决了我的问题
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"/>
在头