我设置谷歌地图,它工作正常,但只是发现不再触发任何提示将受到欢迎我没有在控制台中收到任何错误消息,这更令人讨厌,所以不太确定为什么它不工作:
<div class="img-thumbnail">
<div id="map_canvas"></div>
</div>
<script>
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&' +
'callback=initialize';
document.body.appendChild(script);
}
window.onload = loadScript;
function initialize() {
var map_options = {
center: new google.maps.LatLng(51.500690, -0.152819),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map_canvas'), map_options);
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(51.500690, -0.152819)
});
infowindow = new google.maps.InfoWindow({content:"<b>The Caledonian Club</b><br/>9 Halkin Street<br/>London<br />SW1X 7DR" });
google.maps.event.addListener(marker, "click", function(){
infowindow.open(map,marker);
});
infowindow.open(map,marker);
}
</script>