<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>
有我的代码来生成我的自动完成位置文本输入。Google 的支持类型列表 ( http://code.google.com/apis/maps/documentation/places/supported_types.html ) 将“locality”显示为当我不希望所有内容都返回时使用的类型结果(企业等)。我没有得到任何结果。
基本上,我想要实现的是搜索一个城市(即:多伦多)并且只看到如下结果:“多伦多,安大略省,加拿大”。也许我对如何实现这个 API 感到困惑。
非常感谢您的回复!