I'm trying to print a map div using only L.browserPrint({ position: 'topright' }).addTo(map); and it works fine when map is empty.
As soon as I put my polygons and layers it doesn't work anymore. I'm gettint this error:
I've tried to disable messagebox, canvas and an L.control I use to display a legend, but no success :(
var camadas = L.featureGroup().addTo(map);
var popup = L.popup();
function plotarPoligonos() {
map.closePopup();
camadas.clearLayers();
// var WEIGHT = 1, FILL_OPACITY = .50;
for (var i = 0; i < $scope.retornoPesquisa.length; i++) {
var polParse = JSON.parse($scope.retornoPesquisa[i].Poligono);
if ($scope.retornoPesquisa[i].HtmlRetorno && $scope.retornoPesquisa[i].HtmlRetorno.length > 0) {
polParse.properties.HtmlRetorno = $scope.retornoPesquisa[i].HtmlRetorno;
var _templateScope = $scope.$new();
var compiled = $compile(polParse.properties.HtmlRetorno)(_templateScope);
polParse.properties.Popup = compiled[0];
}
polParse.properties.CorPoligono = $scope.retornoPesquisa[i].CorPoligono;
var pol = L.geoJSON(polParse, {
onEachFeature: function (feature, layer) {
if (polParse.properties.HtmlRetorno && polParse.properties.HtmlRetorno.length > 0) {
layer.on('click', function (e) {
popup.setLatLng(e.latlng).setContent(feature.properties.Popup);
popup.openOn(map);
});
}
},
style: function (feature) {
return {
fillColor: polParse.properties.CorPoligono,
color: 'grey',
weight: 1,
fillOpacity: 0.5
};
}
}).addTo(camadas);
}
map.fitBounds(camadas.getBounds());
};