michimau
(Mauro Michielon)
January 23, 2018, 9:00pm
1
I have a plugin which make use of leaflet, it used to work fine under 5.5.
Under 6.1.x i bump into:
Unhandled promise rejection Error: Map container not found.
in my controller.js have:
"var map = null;
map = L.map('.map-vis', {
scrollWheelZoom: true,
wheelPxPerZoomLevel: 5,
wheelDebounceTime: 40,
zoomDelta: 0.5,
center: [53, 11],
zoom: 4,
maxZoom: 30,
minZoom: 3
});"
my vis template is:
"< div ng-controller="leafletwmsController" >
< div class="map-vis">
< /div >
< /div >"
it looks like "map-vis" does not exists when it is used in the controller.js.
any clue why it stopped to work under 6?
best
michimau
Try wrapping map initialization inside $timeout(initMap, 0);
. This will allow the current digest cycle to finish and the DOM to be updated before calling your initMap functionality.
michimau
(Mauro Michielon)
January 25, 2018, 2:45pm
3
Thank you Nathan,
i am not sure i can follow your advice tho
With the same outcome, I have tried both:
setTimeout(initMap(), 0);
function initMap() {
var mymap = L.map('map-vis').setView([51.505, -0.09], 13);
}
$timeout(initMap(), 0);
function initMap() {
var mymap = L.map('map-vis').setView([51.505, -0.09], 13);
}
var initMap = function () {
var mymap = L.map('map-vis').setView([51.505, -0.09], 13);
}
$timeout(initMap(), 0);
if you want to have a deeper look, i have uploaded a minimalistic example:
import { uiModules } from 'ui/modules';
const module = uiModules.get('kibana/leaflet-wms_values_vis', ['kibana']);
//import { leafletwms } from 'leaflet.wms';
module.controller('leafletwmsController', function($scope, $element, $rootScope, Private) {
console.log (L);
var map = null;
map = L.map('#map-vis', {
scrollWheelZoom: true,
wheelPxPerZoomLevel: 5,
wheelDebounceTime: 40,
zoomDelta: 0.5,
center: [53, 11],
zoom: 4,
maxZoom: 30,
minZoom: 3
});
$scope.$watchMulti(['esResponse', 'vis.aggs'], function([resp]) {
This file has been truncated. show original
michimau
(Mauro Michielon)
February 5, 2018, 7:38am
4
I was distracted by other matters and i forgot to comment. I confirm you nailed it
Thanks
system
(system)
Closed
March 5, 2018, 7:38am
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.