Google maps 谷歌API 3在一段时间后到期

Google maps 谷歌API 3在一段时间后到期,google-maps,google-maps-api-3,jquery-gmap3,Google Maps,Google Maps Api 3,Jquery Gmap3,我正在使用在我的一个web应用程序中生成Google地图。 目前,我将下载到本地驱动器,并在HTML页面中使用相同的 然而,所有的动作对我来说都很好,但3-4天后谷歌API停止工作。如果我从同一个链接下载新的谷歌API到我的本地驱动器,一切都会正常工作。造成这种问题的原因可能是什么?是因为API密钥吗?还是因为我下载到本地驱动器并从本地引用它 但我正在下载谷歌地图API3,它不需要API密钥 代码如下: <script src="/site_media/js/google-map.js"

我正在使用在我的一个web应用程序中生成Google地图。 目前,我将下载到本地驱动器,并在HTML页面中使用相同的

然而,所有的动作对我来说都很好,但3-4天后谷歌API停止工作。如果我从同一个链接下载新的谷歌API到我的本地驱动器,一切都会正常工作。造成这种问题的原因可能是什么?是因为API密钥吗?还是因为我下载到本地驱动器并从本地引用它

但我正在下载谷歌地图API3,它不需要API密钥

代码如下:

<script src="/site_media/js/google-map.js" type="text/javascript"></script>
<script type="text/javascript" src="/site_media/js/gmap3.js"></script> 
<script type="text/javascript">
    $(function(){
    $('#facility_map').gmap3(
        {    
      action:'init',
      options:{
                center:[26.327475, 50.20134],
            zoom: 18,
                mapTypeId: google.maps.MapTypeId.HYBRID
          }
        },      
            {
     action:'getRoute',
     options:{
               origin:['26.327475', '50.20134'], 
               destination:['{{facility.latitude}}', '{{facility.longitude}}'],
           travelMode: google.maps.DirectionsTravelMode.DRIVING
              },
     callback: function(results)
        { 
           if (!results) return;
           $(this).gmap3(
            { 
              action:'addDirectionsRenderer',
              options:{      
                            preserveViewport: true,         
                directions:results
                  }
            });
        }   
    },
           {
             action:'getDistance',
             options:{ 
                      origins:[['26.327475', '50.20134']], 
              destinations:[['{{facility.latitude}}', '{{facility.longitude}}']],
              travelMode: google.maps.TravelMode.DRIVING
             },
      callback: function(results)
      {
        var html = '';
        if (results)
            {
          for (var i = 0; i < results.rows.length; i++)
          {
         var elements = results.rows[i].elements;
         for(var j=0; j<elements.length; j++)
         {
            switch(elements[j].status)
           {
             case google.maps.DistanceMatrixStatus.OK:
                  html += results.destinationAddresses[j]+" -<b> "+elements[j].distance.text + ' (' + elements[j].duration.text + '</b>)<br />';
             break;
             case google.maps.DistanceMatrixStatus.NOT_FOUND:
              html += 'The origin and/or destination of this pairing could not be geocoded<br />';
             break;
             case google.maps.DistanceMatrixStatus.ZERO_RESULTS:
                  html += 'No route could be found between the origin and destination.<br />';
              break;
            }
        }
      } 
       } 
        else 
        {
           html = 'error';
         }
         $('#distance_msg').html("Distance From Rezayat Head Office Khobar to "+html);
       }
     }
    ); 
    });


</script>  

$(函数(){
$(“#设施地图”).gmap3(
{    
操作:'init',
选项:{
中间:[26.327475,50.20134],
缩放:18,
mapTypeId:google.maps.mapTypeId.HYBRID
}
},      
{
操作:'getRoute',
选项:{
产地:['26.327475','50.20134'],
目的地:[{facility.latitude}}',{{facility.longitude}}],
travelMode:google.maps.Directions travelMode.DRIVING
},
回调:函数(结果)
{ 
如果(!results)返回;
$(本文件)。gmap3(
{ 
操作:'addDirectionsRenderer',
选项:{
对,,
方向:结果
}
});
}   
},
{
操作:'getDistance',
选项:{
来源:['26.327475','50.20134']],
目的地:[{facility.latitude}}',{{facility.longitude}}],
travelMode:google.maps.travelMode.DRIVING
},
回调:函数(结果)
{
var html='';
如果(结果)
{
对于(var i=0;i对于(var j=0;j您是否将以下文件保存到硬盘驱动器/web应用程序中:

如果是这样,那么你的问题的答案

还是因为我下载到本地驱动器并引用了它 从本地来

…是的

你引用的文件是缓存的,所以它总是在变化。我从来没有使用过你上面提到的jQuery地图插件(虽然它看起来很酷!),但在查看它们的API时,它提到你应该从Google调用该脚本,而不是直接存储它

此外,请记住,让谷歌为您处理JS负载和带宽,并尽量避免在本地存储。API可能会发生变化,而您的缓存版本可能会导致地图损坏,因为它没有加载最新版本


我还将添加一件事:让我们也来吧-使用该网站的人会有更好的体验。本文将对此进行详细解释。

地图api引导文件包含的代码每隔这么多小时就会使其失效,以专门防止这种情况。@Chand Killingsworth:所以我需要通过URL而不是从loc引用外部的地图apial drive?是的,您必须在外部参考它。