Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jestelle opened this issue Dec 17, 2021 · 1 comment
Open

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

jestelle opened this issue Dec 17, 2021 · 1 comment

Comments

@jestelle
Copy link

jestelle commented Dec 17, 2021

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
Copy link

johnd0e commented Dec 18, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants