I am facing this issue with openUI5 and Leafletjs using a custom control from library.
Error:
"The renderer for class demo.map.SimpleMap is not defined or does not define a render function! Rendering of __map0 will be skipped!"...
library.js
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/library'],
function(jQuery){
"use strict";
sap.ui.getCore().initLibrary({
name: 'demo.map',
version: '1.0.0',
dependencies: ['sap.ui.core'],
types: [],
interfaces: [],
controls:[
'demo.map.SimpleMap'
],
elements:[]
});
return demo.map;
});
SimpleMap.js
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/Control',
'./library'], function(jQuery, Control, library){
"use strict";
let SimpleMap = Control.extend('demo.map.SimpleMap',{
metadata:{
library: 'demo.map',
properties:{}
}
});
SimpleMap.prototype.drawMap = function(){
this.controlAspect = parseInt(450) / parseInt(350);
let map = L.map('map').setView([39.7166700,-8],8);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
}
SimpleMap.prototype.onAfterRendering = function(){
this.drawMap();
}
return SimpleMap;
}, true);
SimpleMapRenderer.js
sap.ui.define(['jquery.sap.global'], function(jQuery){
"use strict";
let SimpleMapRenderer = {};
SimpleMapRenderer.renderer = function(oRm, oControl){
oRm.write('<div ');
oRm.writeControlData(oControl);
oRm.write('>');
oRm.write('</div>');
}
return SimpleMapRenderer;
});
Startpage.view.xml
<mvc:View controllerName="sap.ui.demo.fiori.controllers.Startpage" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:layout="sap.ui.layout">
<Page title="Fiori Tile Demo">
<layout:VerticalLayout class="sapUiResponsiveMargin">
<Title titleStyle="H2" text="Launchpad Menu" class="sapUiTinyMarginBegin"/>
<layout:HorizontalLayout allowWrapping="true" id="layout">
</layout:HorizontalLayout>
</layout:VerticalLayout>
</Page>
</mvc:View>
Startpage.controller.js
sap.ui.define(['sap/ui/demo/fiori/controllers/BaseController'], function(Controller){
"use strict";
return Controller.extend('sap.ui.demo.fiori.controller.Startpage',{
onInit:function(){
console.log('Startpage loaded');
let map = new demo.map.SimpleMap();
//console.log(map);
let oLay = this.getView().byId('layout');
oLay.addContent(map);
},
gotoUserList: function(){
this.getRouter().navTo('listUsers');
},
getRouter: function(){
return this.getOwnerComponent().getRouter();
}
});
});
Also, I have tried to add the map object directly from controller without custom control, but i got below error
'Map container not found' error from Leafletjs framework.
Hope someone please help me. I am pretty lost in how to render leaflet using openUI5.