autocomp = new google.maps.places.Autocomplete(
document.getElementById('shipping_address_1')),
{
types: ['geocode'],
componentRestrictions: {country: "us"}
});
如果您想这样做,可以使用webserviceapi,发送HTTP请求并用响应填充字段。
在以加利福尼亚州旧金山为中心的区域内建立含有字符串“阿米巴”的机构的请求:
https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=Amoeba&types=establishment&location=37.76999,-122.44696&strictbounds&key=YOUR_API_KEY
input=Paris&types=geocode
将给出一个包含预测的JSON对象。
{
"status": "OK",
"predictions" : [
{
"description" : "Paris, France",
"id" : "691b237b0322f28988f3ce03e321ff72a12167fd",
"matched_substrings" : [
{
"length" : 5,
"offset" : 0
}
],
... more results
]
}