미리 작성된 Google 지역 정보 자동 완성에 대한 맞춤 UI를 구현하려고하므로 수동으로 결과를 선택할 수 없습니다. 모든 기능은 getPlacePredictions 함수 옵션에서 여러 유형을 사용하지 않을 때 작동하지만 [ '(regions)', '(cities)']를 사용하면 상태가 'invalid request'를 반환합니다.Google 장소에서 여러 유형을 반환하십시오. autocompleteService.getPlacePredictions
잘못된 것이 있습니까? 아니면 불가능합니다. 여러 유형을 반환하려면?
var _this = this;
this.input = $('#zipcode_autocomplete');
this.service = new google.maps.places.AutocompleteService();
this.input.on('input', function() {
return _this.service.getPlacePredictions({
input: _this.input.val(),
types: ['(regions)', '(cities)'],
componentRestrictions: {
country: 'us'
}
}, _this.callback);
});
this.callback = function(predictions, status) {
var i, prediction, _results;
console.log(predictions);
if (status !== google.maps.places.PlacesServiceStatus.OK) {
alert(status);
return;
}
i = 0;
prediction = void 0;
this.results = $('ul.location_results').removeClass('hidden').html('');
_results = [];
while (prediction = predictions[i]) {
this.results.append("<li><span class='location-address'>" + prediction.terms[0].value + "</span><span class='location-state'>" + prediction.terms[prediction.terms.length - 2].value + "</span></li>");
_results.push(i++);
}
return _results;
};
[ '일반적으로 단지 하나의 유형이 허용됨 '] (https://developers.google.com/places/documentation/autocomplete#place_types). – Andy
좋아, 그게 좌절이야, 페이지를 가리켜 주셔서 감사합니다, 나는 그것을 어디서나 찾을 수 없습니다. @ 앤디 만약 당신이 대답을 게시하고 싶다면 그것을 받아 들일 것입니다. – joewoodward
done. 거기에 조금 더 많은 정보가 추가되었습니다. – Andy