如何使用google api for web从address_components获取地点ID?是否有可能获得标题的ID?
答案 0 :(得分:0)
$(document).ready(function() {
$(document).on('change', '#s', function () {
window.setTimeout(function () {
googleMapsLoaded(); }, 300);
});
});
var autocomplete; function initialize() {
var options = {
types : ['(regions)'] };
var input = document.getElementById('s');
autocomplete = new google.maps.places.Autocomplete(input , options, googleMapsLoaded);
}
var map = google.maps.event.addDomListener(window, 'load', initialize);
function googleMapsLoaded(){
var place = autocomplete.getPlace();
console.log(place.place_id);
}