Google Maps v3 API-自动完成(地址) [英] Google Maps v3 API - Auto Complete (address)
本文介绍了Google Maps v3 API-自动完成(地址)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试自动完成我的Google地图应用程序的工作.
Attempting to get auto complete working for my google maps application.
这是当前代码:
HTML
<input type="text" class="clearText" id="address" name="address" value="" size=20 autocomplete="off">
JavaScript
Javascript
var input = document.getElementById('address');
var options = {
componentRestrictions: {country: 'au'}
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
不幸的是,键入地址时没有任何反应.
Unfortunately nothing happens when typing an address.
有什么想法吗?
谢谢.
我实际上收到以下错误:
I'm actually receiving the following error:
未捕获的TypeError:无法读取未定义的属性自动完成"
Uncaught TypeError: Cannot read property 'autocomplete' of undefined
不知道为什么,该代码放置在我的地图初始化函数中.
Not sure why, the code is placed in my map initialize function.
固定.在下面回答.
推荐答案
已修复.自动完成库实际上是一个单独的库,必须显式加载.以下行解决了该问题.
Fixed. The autocomplete library is actually a separate library that must be explicitly loaded. The following line solved the problem.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
这篇关于Google Maps v3 API-自动完成(地址)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文