通过住宿和地点类型自动填写地点

Mal*_*001 6 google-maps autocomplete google-places-api

我希望Googles自动填充建议仅列出住宿和位置.我大部分都试图让住宿类型工作,但没有任何建议出现.

当我从autoComplete变量中删除ac_options时,一切正常,但是当然没有一个建议被特定类型缩小.

    var ac_options = {
        types: ['lodging']
    };

    var input = document.getElementById(this.options.autoCompleteInputId);
    var autocomplete = new google.maps.places.Autocomplete(input, ac_options);

    //bind to input field
    autocomplete.bindTo('bounds', this.gmap);
Run Code Online (Sandbox Code Playgroud)

Dha*_*tel 5

我不认为住宿是有效的选择,按照以下链接...

https://developers.google.com/maps/documentation/javascript/places#places_autocomplete

你应该试着跟随...

https://developers.google.com/maps/documentation/javascript/examples/places-queryprediction

在示例中使用"住宿"代替"披萨附近"... :)