Javascript iframe中Bing地图中的多个位置
我试图让这段代码在iframe中工作,但我总是遇到错误: ReferenceError:未定义GetMap 我不是一个高级程序员,所以我不知道为什么它可以单独工作,但不能在iframe中工作(而且似乎没有人有相同的问题)!非常感谢您的帮助 PS:编程代码主要来自Yomyo(他将其发布在stackoverflow上),我只是根据自己的需要对其进行了修改Javascript iframe中Bing地图中的多个位置,javascript,bing-maps,referenceerror,Javascript,Bing Maps,Referenceerror,我试图让这段代码在iframe中工作,但我总是遇到错误: ReferenceError:未定义GetMap 我不是一个高级程序员,所以我不知道为什么它可以单独工作,但不能在iframe中工作(而且似乎没有人有相同的问题)!非常感谢您的帮助 PS:编程代码主要来自Yomyo(他将其发布在stackoverflow上),我只是根据自己的需要对其进行了修改 <html> <head> <script charset="UTF
<html>
<head>
<script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript" language="JavaScript">
function GetMap() {
var longitude = new Array();
var latitude = new Array();
var title = new Array();
var description = new Array();
longitude[0] = 47.5564154 //two defined locations
latitude[0] = 7.59245395
title[0] = "Basler Münster"
description[0] = "Basel"
longitude[1] = 47.55330556 //second defined Location
latitude[1] = 7.59001851
title[1] = "Theater Basel"
description[1] = "Basel"
var total = 2 //number of locations
var pinInfoBox; //the pop up info box
var infoboxLayer = new Microsoft.Maps.EntityCollection();
var pinLayer = new Microsoft.Maps.EntityCollection();
var apiKey = "AmpgeSj6OVb9ILPwvjyIfwM3qmqm5yccyNGR_mxmbpw2znYZoXxQAz_KVbc84XCC";
map = new Microsoft.Maps.Map(document.getElementById("map"), {credentials: apiKey});
// Create the info box for the pushpin
pinInfobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { visible: false });
infoboxLayer.push(pinInfobox);
for (var i = 0 ; i < total; i++){
//add pushpins
var latLon = new Microsoft.Maps.Location(longitude[i], latitude[i]);
var pin = new Microsoft.Maps.Pushpin(latLon);
pin.Title = title[i];//usually title of the infobox
pin.Description = description[i]; //information you want to display in the infobox
pinLayer.push(pin); //add pushpin to pinLayer
Microsoft.Maps.Events.addHandler(pin, 'click', displayInfobox);
}
map.entities.push(pinLayer);
map.entities.push(infoboxLayer);
map.setView({zoom: 15, center: new Microsoft.Maps.Location(47.55330556, 7.59001851)});
}
function displayInfobox(e)
{
pinInfobox.setOptions({title: e.target.Title, description: e.target.Description, visible:true, offset: new Microsoft.Maps.Point(0,25)});
pinInfobox.setLocation(e.target.getLocation());
}
function hideInfobox(e)
{
pinInfobox.setOptions({ visible: false });
}
</script>
<style>
#map { position: relative; top: 0; left: 0; width: 100%; height: 800px; border:none;}
</style>
</head>
<body onload="GetMap()">
<div id="some stuff" style="width=100%; height:80px">
some text
</div>
<div id="map" style="width=100%; height:800px">
</div>
<div id="some more stuff" style="width=100%; height:80px">
some more text to read
</div>
</body>
</html>
函数GetMap(){
var longitude=新数组();
var latitude=新数组();
var title=新数组();
var description=新数组();
经度[0]=47.5564154//两个定义的位置
纬度[0]=7.59245395
标题[0]=“巴斯勒明斯特”
说明[0]=“巴塞尔”
经度[1]=47.55330556//第二个定义位置
纬度[1]=7.59001851
标题[1]=“巴塞尔剧院”
说明[1]=“巴塞尔协议”
var total=2//位置数
var pinInfoBox;//弹出信息框
var infoboxLayer=new Microsoft.Maps.EntityCollection();
var pinLayer=new Microsoft.Maps.EntityCollection();
var apiKey=“ampgesj6ovb9ilpwvjyifwm3qm5yccyngr_mxmbpw2znyzoxqaz_KVbc84XCC”;
map=new Microsoft.Maps.map(document.getElementById(“map”),{credentials:apiKey});
//为图钉创建信息框
pinInfobox=new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0,0),{visible:false});
infoboxLayer.push(pinInfobox);
对于(变量i=0;i
代码看起来很好,我无法重现您看到的错误 适合我,你用什么浏览器?用IE、FF、Chrome的最新版本进行测试。我使用了Chrome和IE。我试着把它嵌入facebook(fanpage)上,可能是有问题的。我现在切换到谷歌地图。