google.maps.places其自动完成的方法是未定义 [英] google.maps.places and its Autocomplete method are undefined

查看:1040
本文介绍了google.maps.places其自动完成的方法是未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载的谷歌地图API ,的 jQuery的 Geocomplete 插件。
请注意,我还指定库(库=地方的),最终我的 API密钥的:

 <脚本的src =HTTP://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'>< / SCRIPT&GT ;
&LT;脚本src='http://maps.googleapis.com/maps/api/js?v=3&sensor=false&amp;libraries=places&key=xxx'></script>
&LT;脚本的src ='JS /供应商/ jquery.geocomplete.js'&GT;&LT; / SCRIPT&GT;

我触发Geocomplete插件的页面加载

  $(窗口).load(函数(){
    $('#我输入')geocomplete()。
});

但我总是得到一个错误:

未捕获类型错误:无法读取未定义的属性自动完成。[jquery.geocomplete.js:153]

里面的插件...

  this.autocomplete =新google.maps.places.Autocomplete(
 this.input,期权
);

我试过的 google.maps 的,它返回一个普通对象,但地方是的未定义的!


解决方案

  

我试图google.maps并返回一个普通对象,但地方是不确定的!


这意味着google.maps.places库没有加载(code的线,你贴出来,如下图所示要么是不正确或不实际页面上):

 &LT;脚本src='http://maps.googleapis.com/maps/api/js?v=3&sensor=false&amp;libraries=places&key=xxx'></script>

这是从文档的例子:

 &LT;脚本类型=文/ JavaScript的SRC =htt​​p://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&GT ;&LT; / SCRIPT&GT;

唯一明显不同的是&放大器;放大器; 在你的,应该工作,但你应该始终如一地使用它。

I'm loading the Google Maps API, jQuery and this Geocomplete plugin. Please note that I'm also specifying the libraries (libraries=places) and eventually my API key:

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<script src='http://maps.googleapis.com/maps/api/js?v=3&sensor=false&amp;libraries=places&key=xxx'></script>
<script src='js/vendor/jquery.geocomplete.js'></script>

I'm triggering the Geocomplete plugin on the page load

$(window).load(function () {
    $('#my-input').geocomplete();
});

but I always get an error:

Uncaught TypeError: Cannot read property 'Autocomplete' of undefined [jquery.geocomplete.js:153].

Inside the plugin...

this.autocomplete = new google.maps.places.Autocomplete(
 this.input, options
);

I tried to google.maps and it returns a regular object, but places is undefined!

解决方案

I tried to google.maps and it returns a regular object, but places is undefined!

That means the google.maps.places library is not loading (the line of code that you posted, shown below is either not correct or is not actually on your page):

<script src='http://maps.googleapis.com/maps/api/js?v=3&sensor=false&amp;libraries=places&key=xxx'></script>

This is the example from the documentation:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

The only obvious difference is the &amp; in yours, that should work, but you should probably use it consistently.

这篇关于google.maps.places其自动完成的方法是未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆