I am currently creating an SDK to use Bing Maps. When I run the SDK, the bing map isn't show.
The file "component.js" contains the following:
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
});
};
};
});
});
In the file "contribution.xml" this is called by the following code
<requireJs modes="commons m">res/js/component</requireJs>
Does anyone have a hint where the error lies?
Kind regards, Timo
Here is my new code:
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();
});
});