I need to use Here Maps Javascript API library in my application. It works nicely when I run the app standalone(since I include it in index.html). But When I deploy it on HANA Cloud Platform and try to run it inside the HCP Portal site, it fails.
I know I need to load the library files in Component.js since index.html is not used. My issue is that I need to load 4 different js files and one stylesheet before starting to draw the map. I am using jQuery.sap.includeScript()and jQuery.sap.includeStyleSheet() functions to do that but my rootview's onInit and onAfterRendering() is called before the library files are loaded(see their status as "pending"in the Networks Tab in chrome).
I followed the below post:
UsingjQuery.sap.includeScript().then() in HCP Firori Launchpad
How can I load/initialize the view only after the library files are loaded.
Is it correct to do all of this in component.js. Does manifest.json play any role in achieving this.
Any example will be helpful. Thanks in Advance.
My Component init code is as below:
init: function() {
// call the base component's init function
UIComponent.prototype.init.apply(this, arguments);
var that = this;
//Load the here maps library
jQuery.sap.includeScript("https://js.api.here.com/v3/3.0/mapsjs-core.js", "hereMapsCore", $.proxy(function(succ) {
jQuery.sap.includeScript("https://js.api.here.com/v3/3.0/mapsjs-service.js", "hereMapsService", $.proxy(function(succ) {
jQuery.sap.includeScript("https://js.api.here.com/v3/3.0/mapsjs-ui.js", "hereMapsUi", $.proxy(function(succ) {
jQuery.sap.includeScript("https://js.api.here.com/v3/3.0/mapsjs-mapevents.js", "heremapsEvent", $.proxy(function(succ) {
jQuery.sap.includeStyleSheet("https://js.api.here.com/v3/3.0/mapsjs-ui.css", "hereMapscss", $.proxy(function() {
// UIComponent.prototype.init.apply(this, arguments);
// set the device model
this.setModel(models.createDeviceModel(), "device");
var a = this;
}, this));
}, this), function(oErr) {
MessageBox.alert("Map File not loaded");
});
}, this), function(oErr) {
MessageBox.alert("Map File not loaded");
});
}, this), function(oErr) {
MessageBox.alert("Map File not loaded");
});
}, this), function(oErr) {
MessageBox.alert("Map File not loaded");
});
}