我目前正在使用给定的代码,但这仅限于向一个国家/地区提出建议.我见过一个实现,但它使用jQuery,我想在不使用jQuery的情况下完成它.
var input = document.getElementById('searchTextField');
var options = {
//types: ['(cities)'],
componentRestrictions: { country: 'pk' }
};
var autocomplete = new google.maps.places.Autocomplete( input, options );
Run Code Online (Sandbox Code Playgroud) google-maps autocomplete google-maps-api-3 google-places-api