Bing地图没有加载

时间:2014-10-30 18:40:59

标签: javascript html phantomjs bing-maps

我使用这个html来加载bing map脚本:

<html><head>
    <script src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"     type="application/javascript" ></script>
</head><body></body></html>

在firefox中:脚本加载并添加另一个脚本标记到head,然后加载第二个脚本(可以在firebug Net选项卡中看到):

<html><head>
    <script src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"     type="application/javascript" ></script>
    <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/v7.0/7.0.20140904153057.64/js/en-us/veapicore.js">
</head><body></body></html>

在phantomjs中:我挂钩到page.onResourceRequested并打印请求网址。结果是只请求了第一个脚本,因为我不知道的原因不请求veapicore.js。

这里发生了什么?

1 个答案:

答案 0 :(得分:0)

我认为这与RequireJS的问题相同。在Web浏览器中,当您动态加载脚本时,如果脚本位于不同的域中,则无法动态加载其他脚本。这是一件安全事。

只需像平常一样加载脚本代码,或者查看此博文:http://rbrundritt.wordpress.com/2011/11/20/bing-maps-v7-control-lazy-loader/