<html>
<head>
<title></title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var input = document.getElementById('location');
var options = {
types: ["locality"]
};
autocomplete = new google.maps.places.Autocomplete(input, options);
});
</script>
</head>
<body>
<div>Location: <input type="text" id="location" style="width:400px;" /></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有我的代码生成我的自动完成位置文本输入.谷歌的支持的类型的列表(http://code.google.com/apis/maps/documentation/places/supported_types.html)显示"本地"作为要使用的类型时,我不想要的一切回来的结果(企业等).我没有结果.
基本上,我想要实现的是搜索一个城市(IE:多伦多)并且只看到如下结果:"Toronto,ON,Canada".也许我对如何实现此API感到困惑.
非常感谢您的回复!
我认为你正在寻找根据文档的选项是"地址解析"(http://code.google.com/apis/maps/documentation/javascript/reference.html#AutocompleteOptions):
var options = {
types: ["geocode"]
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20967 次 |
| 最近记录: |