【发布时间】:2020-10-04 13:45:56
【问题描述】:
我正在尝试让自动完成的 Google MAP API 正常工作。但是,每当我加载页面时,我都会收到错误“未捕获的 ReferenceError: google is not defined”
HTML
<label>Location</label>
<input id="location_field" type="text" class="form-control" placeholder="Location">
JAVASCRIPT
let locationField = document.getElementById('location_field');
let autocomplete = new google.maps.places.Autocomplete(locationField);
google.maps.event.addListener(autocomplete, 'place_changed', function () {
let place = autocomplete.getPlace();
specifiedLocationObject = place;
});
我总是在这条线路上得到错误:
let autocomplete = new google.maps.places.Autocomplete(locationField);
【问题讨论】:
-
您是否尝试过将您的代码与工作中的google example in the documentation 进行比较?
标签: javascript html google-maps google-maps-api-3