5

如何强制使用 Google Place API 的自动完成功能来完成带有邮政编码的 textView?

我试过使用这个链接:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=20&types=postal_code&language=de&sensor=false&key=myKey

获取以 20 开头的邮政编码,但它不起作用。我从服务器收到以下响应:

{
   "predictions" : [],
   "status" : "INVALID_REQUEST"
}

我怎样才能使它工作>

4

1 回答 1

3

The problem with your request is that postal_code is not a valid type to pass to the AutoComplete endpoint. If you look at place types for the AutoComplete endpoint you can see the four allowed types are geocode, establishment, (regions), and (cities). The closest you can get to what your looking for is setting the type to "types=(regions)".

This will return any result that has one or more of the following types :

  • locality
  • sublocality
  • postal_code
  • country
  • administrative_area1
  • administrative_area2
于 2013-07-15T21:20:31.400 回答