filter only sublocalities in google maps api

后端 未结 2 1337
迷失自我
迷失自我 2021-01-27 03:58

I want to get nearby sublocalities in google maps api

var input = document.getElementById(\'searchTextField\');         
    var autocomplete = new google.maps.p         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-27 04:37

    Types: ["(cities)"] will give you just localities.

    From the documentation :

    "types | Type: Array | The types of predictions to be returned. Four types are supported: 'establishment' for businesses, 'geocode' for addresses, '(regions)' for administrative regions and '(cities)' for localities. If nothing is specified, all types are returned."

    var input = document.getElementById('searchTextField');         
    var autocomplete = new google.maps.places.Autocomplete(input, {
        types: ["(cities)"]
    }); 
    

提交回复
热议问题