From 13eb66570a291a47df431c4756950d69c991ac4f Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 19 Oct 2024 17:39:22 -0500 Subject: [PATCH] Warn if custom layer source may not be GeoJSON --- main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.js b/main.js index e1ce3a6..c535e2a 100644 --- a/main.js +++ b/main.js @@ -164,6 +164,11 @@ const sourceInput = customLayerDiv.querySelector('input[name=source]'); const colorInput = customLayerDiv.querySelector('input[name=color]'); customLayerDiv.querySelector("button").addEventListener("click", function(){ + if (!sourceInput.value.toLowerCase().endsWith(".geojson")) { + if (!confirm("Input URL doesn't end in .geojson, so is probably not a valid GeoJSON file. Do you want to continue anyway?")) { + return; + } + } newCustomLayer(labelInput.value, sourceInput.value, colorInput.value); }); document.querySelector("aside").appendChild(customLayerDiv);