Igor-Vladyka / leaflet.browser.print

A leaflet plugin which allows users to print the map directly from the browser
https://igor-vladyka.github.io/leaflet.browser.print/
MIT License
155 stars 76 forks source link

Problem trying to print Map #2

Closed pedrovsra closed 7 years ago

pedrovsra commented 7 years ago

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: image I've tried to disable messagebox, canvas and an L.control I use to display a legend, but no success :(

That's the code I use to plot my polygons on map:

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());
    };
Igor-Vladyka commented 7 years ago

Hi Pedro,

What version of Leaflet are you using?

Also, please create jsbin with your problem. Or at least specify $scope.retornoPesquisa array to reproduce your issue.

But right now I'm pretty sure that there is some kind of problem with your polygon data due to error call stack.

Igor-Vladyka commented 7 years ago

Not a plugin issue.