【发布时间】:2019-11-22 16:00:20
【问题描述】:
我目前正在创建一个 SDK 以使用 Bing 地图。当我运行 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, 13.4225),
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
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();
});
});
【问题讨论】:
-
没人知道吗?
标签: sdk requirejs bing-maps sap-lumira