【问题标题】:Mixed Content using Google Maps使用谷歌地图的混合内容
【发布时间】:2017-04-29 03:38:03
【问题描述】:

我在我的网站上使用 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

【问题讨论】:

  • 你试过用//设置谷歌脚本吗?

标签: google-maps https zk mixed-content


【解决方案1】:

来自ZK demo of google maps

<gmaps version="3.26" id="gmaps" width="520px" height="400px" showSmallCtrl="true" protocol="https">

您可以尝试添加协议属性吗?

【讨论】:

  • 您能提供反馈吗?
【解决方案2】:

我解决了我的问题,将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***" />

【讨论】:

    【解决方案3】:

    添加以下内容并解决了我的问题

    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"/>
    

    在头脑中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-16
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 2011-08-17
      • 1970-01-01
      • 2016-06-28
      相关资源
      最近更新 更多