Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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
Jquery setTimeout回调中出现异常:ReferenceError:未定义google_Jquery_Meteor_Google Maps Api 3_Meteor Blaze_Geocomplete - Fatal编程技术网

Jquery setTimeout回调中出现异常:ReferenceError:未定义google

Jquery setTimeout回调中出现异常:ReferenceError:未定义google,jquery,meteor,google-maps-api-3,meteor-blaze,geocomplete,Jquery,Meteor,Google Maps Api 3,Meteor Blaze,Geocomplete,我想我一次又一次地提出同样的问题。我一直在尝试设置Geocomplete以使用我的Meteor js应用程序 同样的代码在非Meteor应用程序上运行得非常好,但在Meteor js应用程序上却很难执行。在阅读了论坛上的许多建议后,我提出了这个代码。运行它会产生以下错误 Onrendered函数代码: Template.geolayout.onRendered(function(){ Meteor.setTimeout(function () { $(function (

我想我一次又一次地提出同样的问题。我一直在尝试设置Geocomplete以使用我的Meteor js应用程序

同样的代码在非Meteor应用程序上运行得非常好,但在Meteor js应用程序上却很难执行。在阅读了论坛上的许多建议后,我提出了这个代码。运行它会产生以下错误

Onrendered函数代码:

Template.geolayout.onRendered(function(){
    Meteor.setTimeout(function () {
        $(function () {
        $('body').append('<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyA55ihs_QPBpO5r465dgdfg1TJ0FX4ofL8zk&libraries=places">');
        $('body').append('<script src="/js/jquery.geocomplete.js">');
        
            $("#geocomplete").geocomplete({
              map: ".map_canvas",
              details: "form",
              types: ["geocode", "establishment"],
            });

            $("#find").click(function(){
              $("#geocomplete").trigger("geocode");
            });
        });
    }, 200);
});
Template.geolayout.onRendered(函数(){
Meteor.setTimeout(函数(){
$(函数(){
$('body')。追加('');
$('body')。追加('');
$(“#地理完整”)。地理完整({
地图:“.map_canvas”,
详情:“表格”,
类型:[“地理编码”、“机构”],
});
$(“#查找”)。单击(函数(){
$(“#地理完整”).trigger(“地理代码”);
});
});
}, 200);
});
火焰代码

<template name="geolayout">
      <div class="map_canvas"></div>

    <form>
      <input id="geocomplete" type="text" placeholder="Type in an address" value="Empire State Bldg" />
      <input id="find" type="button" value="find" />

      <fieldset>
        <h3>Address-Details</h3>

        <label>Name</label>
        <input name="name" type="text" value="">

        <label>URL</label>
        <input name="url" type="text" value="">

        <label>Website</label>
        <input name="website" type="text" value="">
      </fieldset>
    </form>

</template>

地址详情
名称
统一资源定位地址
网站
控制台上的错误:

Exception in setTimeout callback: ReferenceError: google is not defined
    at GeoComplete.$.extend.initMap (eval at <anonymous> (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), <anonymous>:123:22)
    at GeoComplete.$.extend.init (eval at <anonymous> (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), <anonymous>:105:12)
    at new GeoComplete (eval at <anonymous> (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), <anonymous>:99:10)
    at HTMLInputElement.eval (eval at <anonymous> (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), <anonymous>:586:22)
    at Function.jQuery.extend.each (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:442:23)
    at jQuery.fn.jQuery.each (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:194:17)
    at $.fn.geocomplete (eval at <anonymous> (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), <anonymous>:582:19)
    at HTMLDocument.<anonymous> (http://localhost:3000/app/app.js?hash=a15884274aa7ef8a6a17bc31acbc671588e8bcb5:568:22)
    at fire (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:3201:30)
    at Object.self.add [as done] (http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:3247:7)
setTimeout回调中的异常:ReferenceError:未定义google 在GeoComplete.$.extend.initMap(在(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), :123:22) 在GeoComplete时。$.extend.init(在(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), :105:12) 在新的地理位置完成(评估在(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), :99:10) 在HTMLInputElement.eval(eval在(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), :586:22) 在Function.jQuery.extend.each(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:442:23) 在jQuery.fn.jQuery.each(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:194:17) 在$fn.geoplete(评估在(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:397:22), :582:19) 在HTMLDocument。(http://localhost:3000/app/app.js?hash=a15884274aa7ef8a6a17bc31acbc671588e8bcb5:568:22) 着火(http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:3201:30) 在Object.self.add[完成时](http://localhost:3000/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad:3247:7)
只需移动main.html末尾的2个scripts标记。这会让你的生活更轻松

<body>
  {{> geolayout}}

  <script src="http://maps.googleapis.com/maps/api/js?key=YOUR_KEY&libraries=places"></script>
  <script src="/js/jquery.geocomplete.js"></script>
</body>

{{>地理布局}

用API密钥替换您的\u密钥。

您的意思是在geolayout模板的末尾和关闭之前?不,在您的最后。我为您脱帽致敬。我已经做了好几天了。言语无法表达我的感激之情。