我有一个带有输入框的谷歌地图来搜索位置。当我加载页面时,我在下图中显示的控制台上收到错误。我检查并发现该错误来自geocomplete()。bind函数。这些是我尝试过的代码。任何人都可以帮助我,为什么我会收到这个错误。
<div class="box-search">
<input id="geocomplete" type="text" class="inputtxt-style -search" placeholder="Search Location">
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=1&libraries=places&callback=initialize" async defer></script>
<script src="https://maps.googleapis.com/maps/api/js?key=1&libraries=places&callback=initialize"
async defer></script>
<script type="text/javascript" src="assets/js/jquery.geocomplete.min.js"></script>
<script>
function initialize()
{
//google map and marker code
$("#geocomplete")
.geocomplete()
.bind("geocode:result", function(event, result){
var searchLocation = result.geometry.location;
var searchLatitude = searchLocation.lat();
var searchLon = searchLocation.lng();
var myLatlng = new google.maps.LatLng(parseFloat(searchLatitude),parseFloat(searchLon));
mapSingle.panTo(myLatlng);
});
}
</script>