我試圖在同一個網頁上顯示兩個Bing地圖,但是我的代碼僅顯示第二個地圖(請參閱下面的代碼)。Bing地圖:網頁上的兩個地圖
我已經嘗試過使用異步(腳本在<body>
結束時)和同步(腳本在<head>
之內)選項,但我遇到了同樣的錯誤。
任何想法如何解決它?欣賞它!
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id='printoutPanel'></div>
<h1>Map 1: </h1>
<div id='myMap' style='width: 30vw; height: 30vh;'></div>
<h1>Map 2:</h1>
<div id='myMap2' style='width: 30vw; height: 30vh;'></div>
<script type='text/javascript'>
function loadMapScenario() {
var loc1 = new Microsoft.Maps.Location(48.777677, 9.180600); //Schloßplatz coords
var navigationBarMode1 = Microsoft.Maps.NavigationBarMode;
var map1 = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials: 'My Bing Maps Key',
navigationBarMode: navigationBarMode1.compact, //uncomment to show/hide compact navigation bar
center: loc1,
zoom: 16,
});
}
</script>
<script type='text/javascript'>
function loadMapScenario() {
var loc2 = new Microsoft.Maps.Location(48.777677, 9.180600); //Schloßplatz coords
var navigationBarMode2 = Microsoft.Maps.NavigationBarMode;
var map2 = new Microsoft.Maps.Map(document.getElementById('myMap2'), {
credentials: 'My Bing Maps Key',
navigationBarMode: navigationBarMode2.compact, //uncomment to show/hide compact navigation bar
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
center: loc2,
zoom: 16,
});
}
</script>
<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=experimental&callback=loadMapScenario' async defer></script>
</body>
非常感謝,我修好了。 – Camilo