1

I am having difficulty understanding the following error message.enter image description here

enter image description here

    var okombahe_erven = L.tileLayer.betterWms("http://localhost:8080/geoserver/Erongo/wms", {
    layers: 'okombahe_erven',
    format: 'image/png',
    transparent: true,
    attribution: '',
  });

  var map = L.map('map', {
    zoomControl:true,
    zoom: 14,
    maxZoom:25,
    minZoom:5,
    center: new L.LatLng(-21.3665370941162, 15.3731527328491),

    layers: [OSM, okombahe_erven]
  });

  var baseMaps = {
    "OpenStreetMap": OSM,
    "ESRI  World Imnagery": Esri_WorldImagery
  };
  var overlayMaps = {

    "Zonning": okombahe_erven,
  };
  L.control.layers(baseMaps, overlayMaps).addTo(map);

var logo = L.control({position: 'topright'});
logo.onAdd = function (map) {
    var div = L.DomUtil.create('div', 'logo');
    div.innerHTML = "<img src='./images/North_Arrow.svg' height='50px'/></a>";
    return div;
};

map.on("browser-print-start", function(e){

    for (let key in control.getOverlays()) {
        function printer(layer_name) {
            console.log(layer_name);
            layer_name.addTo(e.printMap);

        }

        if (control.getOverlays()[key] !== true) {
            continue;
        }
        var map_legend = key.concat('_legend');
        okombahe_erven_legend.addTo(e.printMap);
        logo.addTo(e.printMap);

    }

});
var customActionToPrint;
customActionToPrint = function (context, mode) {
    return function () {
        window.alert(" Select Specific area to print the map!");
        context._printCustom(mode);
    }
};

L.control.browserPrint({
    title: '',
    documentTitle: '',

    closePopupsOnPrint: true,
    printModes: [
        L.control.browserPrint.mode("Alert", "User specified print action", "A6", customActionToPrint, false),
        L.control.browserPrint.mode.landscape(),
        "Portrait"
    ],
    manualMode: false
}).addTo(map);

  var okombahe_erven_legend = L.control({position: 'bottomright'});
    okombahe_erven_legend.onAdd = function (map) {
    var div = L.DomUtil.create('div', 'info legend');
        div.innerHTML +=
        '<span><img src='+""+' height="20px" align="top";>&nbsp;&nbsp;&nbsp;</span></br>';
    return div;
    };  


  okombahe_erven_legend.addTo(map);
    map.on('overlayadd', function (eventLayer) {

    if (eventLayer.name === 'Zonning') {
        this.removeControl(okombahe_erven_legend);
        okombahe_erven_legend.addTo(this);
    }
            else { 
        this.removeControl(zoning_legend);

    }
});
  • This simply means that object control is not defined, or to be more accurate, is not defined in such a way to be accessible to event processing function. What should this control object be? – TomazicM Mar 6 at 8:32
  • I believe control is not defined in a way that is accessing to event processing function because I used the same printing on another map that is structured differently and it works fine. I have updated the code. – Amelia Nicodemus Mar 6 at 9:00
  • What your are missing is declaration of print control object when defining it: var control = L.control.browserPrint({ .... – TomazicM Mar 6 at 9:06
  • 1
    You are deleting comments that were later answered by comment from somebody else. Without your comment, answering comment of course has no meaning. That's not correct practice, please refrain from it in the future. – TomazicM Mar 7 at 21:12

Browse other questions tagged or ask your own question.