iitc-project / ingress-intel-total-conversion

ingress.com/intel total conversion user script with some new features. Should allow easier extension of the intel map.
http://iitc.jonatkins.com/
ISC License
991 stars 553 forks source link

layer-count plugin broken when draw-tools is also installed #1319

Open jestelle opened 2 years ago

jestelle commented 2 years ago

If draw-tools is installed, something goes wrong in layer-count and it doesn't work.

I fixed it by basically disabling the chunk of code that interacts with draw tools.

Here's my local fix:

` plugin.layerCount.onBtnClick = function(ev) { var btn = plugin.layerCount.button, tooltip = plugin.layerCount.tooltip, layer = plugin.layerCount.layer;

var drawToolsEnabled = false;

if(btn.classList.contains("active")) {
    if(window.plugin.drawTools !== undefined && drawToolsEnabled) {
        window.plugin.drawTools.drawnItems.eachLayer(function(layer) {
            if (layer instanceof L.GeodesicPolygon) {
                L.DomUtil.addClass(layer._path, "leaflet-clickable");
                layer._path.setAttribute("pointer-events", layer.options.pointerEventsBackup);
                layer.options.pointerEvents = layer.options.pointerEventsBackup;
                layer.options.clickable = true;
            }
        });
    }
    map.off("click", plugin.layerCount.calculate);
    btn.classList.remove("active");
} else {
    console.log("inactive");
    if(window.plugin.drawTools !== undefined && drawToolsEnabled) {
        window.plugin.drawTools.drawnItems.eachLayer(function(layer) {
            if (layer instanceof L.GeodesicPolygon) {
                layer.options.pointerEventsBackup = layer.options.pointerEvents;
                layer.options.pointerEvents = null;
                layer.options.clickable = false;
                L.DomUtil.removeClass(layer._path, "leaflet-clickable");
                layer._path.setAttribute("pointer-events", "none");
            }
        });
    }
    map.on("click", plugin.layerCount.calculate);
    btn.classList.add("active");
    setTimeout(function(){
        tooltip.textContent = "Click on map";
    }, 10);
}

}; `

johnd0e commented 2 years ago

https://github.com/IITC-CE/ingress-intel-total-conversion