我当前正在创建一个使用Bing Maps的SDK。当我运行SDK时,bing地图没有显示。
文件“ component.js”包含以下内容:
define(["sap/designstudio/sdk/component","d3"],function(Component,d3,unusedDummy) {
Component.subclass("com.xxx.bingmaps.BingMaps",function() {
this.init = function() {
var url = 'http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[MY_BING_KEY]';
const script = document.createElement("script");
script.type = 'text/javascript';
script.src = url;
script.async = true;
script.defer = true;
document.head.appendChild(script);
function GetMap() {
this.map = new microsoft.Maps.Map('#myMap',{
center: new microsoft.Maps.Location(52.527222,13.4225),mapTypeId: microsoft.Maps.MapTypeId.aerial,zoom: 10
});
};
};
});
});
在文件“ contribution.xml”中,以下代码将其调用
<requireJs modes="commons m">res/js/component</requireJs>
有人暗示错误在哪里吗?
亲切的问候, 蒂莫
这是我的新代码:
define(["d3","sap/designstudio/sdk/component"],function(d3,Component) {
function GetMap() {
var map = new microsoft.Maps.Map('#BingMaps',{
center: new microsoft.Maps.Location(52.527222,zoom: 10
});
};
Component.subclass("com.xxx.bingmaps.BingMaps",function() {
this.init = function() {
var url = 'https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[MY_KEY]';
const script = document.createElement("script");
script.type = 'text/javascript';
script.src = url;
script.async = true;
script.defer = true;
document.head.appendChild(script);
};
GetMap();
});
});