         listOfUnits?.remove()
         window.printed = true
 
+    # Add print event listeners
     (() ->
+        # webkit
         if window.matchMedia
             mediaQueryList = window.matchMedia('print')
             mediaQueryList.addListener (mql) ->

                delete marker._iconStore
            # Reset icon options
            if marker.options.icon.options.printStore
                marker.options.icon.options = Object.assign({}, marker.options.icon.options, marker.options.icon.options.printStore)
                delete marker.options.icon.options.printStore

        images = document.getElementById('images')

                    for own mcid, mc of markerCluster._childClusters
                        unitNames = unitNames.concat getClusteredUnits(mc)
                    unitNames

                if marker instanceof L.MarkerCluster
                    # Adjust the icon anchor position for clusters with these magic numbers
                    marker.options.icon.options.iconAnchor = new L.Point(5*iconSize/6, iconSize / 6)
                    unitNames = getClusteredUnits(marker)
                    for name in unitNames
                        div = document.createElement 'div'
                        div.className = 'printed-unit-name'
                        div.textContent = name
                        markerLegend.appendChild div

                else
                    div = document.createElement 'div'
                    div.className = 'printed-unit-name'
                    div.textContent = marker.unit.attributes.name.fi
                    markerLegend.appendChild div
                listOfUnits.appendChild(markerLegend)
            else # Markers outside the current view

        leafletImage map, (err, canvas) =>
            # now you have canvas
            # example thing to do with that canvas:
            console.log canvas, err
            img = document.createElement 'img'
            img.src = canvas.toDataURL()
            document.getElementById('images').appendChild img
            window.makingPrint = false

    window.onAfterPrint = () =>
        if window.makingPrint
