我的网站上有一个使用 Maps API 创建的嵌入式地图。它在大学会加载 9/10 次,但在家里永远不会加载。有没有办法解决这个问题,使其始终加载。
这是它正在使用的脚本:
<script>
function initMap() {
var pointer = {lat: 53.827369, lng: -1.594245};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: pointer
});
var marker = new google.maps.Marker({
position: pointer,
map: map,
title: 'Leeds Beckett University "Headingley Campus"'
});
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'<\/div>'+
'<h1 id="firstHeading" class="firstHeading">Leeds Beckett University<\/h1>'+
'<div id="bodyContent">'+
'<p class="maptext">Leeds Beckett University is a public university in Leeds, West Yorkshire, with campuses in the city centre and Headingley. The university’s origins can be traced to 1824, with the foundation of the Leeds Mechanics Institute<\/p>' +
'<p class="maptext"><b>Postcode:<\/b> LS1 3HE<\/p>'+
'<\/div>'+
'<\/div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
}
</script>
“map”div 已包含在我的 HTML 中。
看来你的问题是因为你没有打电话initMap
,至少从您提供的代码来看。您能否对这个问题提供更多见解?
$(document).ready(function() {
initMap();
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)