Google地图自动填充Javascript仅限城市

时间:2016-03-21 08:44:02

标签: javascript google-maps google-maps-api-3

如果我输入胡佛(城市),我的页面上有一个自动填充搜索框。它返回此地址美国阿拉巴马州的Hoover,而不是我想要仅捕获城市名称的整个地址。

Hoover,AL,United States

我只需要胡佛

Google Map javaecript:

<script type="text/javascript">
                   function initialize() {
                      var input = document.getElementById('address');
                      var autocomplete = new google.maps.places.Autocomplete(input);
                   }
                   google.maps.event.addDomListener(window, 'load', initialize);


                   function initialize() {
                  var options = {
                          types: ['(cities)'],
                          componentRestrictions: {country: "us"}
                         };


                     var input = document.getElementById('address');
                     var autocomplete = new google.maps.places.Autocomplete(input, options);
                }
</script>

0 个答案:

没有答案