diff --git a/packages/client/src/components/app/embedded-map/EmbeddedMap.svelte b/packages/client/src/components/app/embedded-map/EmbeddedMap.svelte index 2cfe3f497f..3bb7d5606d 100644 --- a/packages/client/src/components/app/embedded-map/EmbeddedMap.svelte +++ b/packages/client/src/components/app/embedded-map/EmbeddedMap.svelte @@ -283,27 +283,32 @@ if (mapInstance) { mapInstance.remove() } - mapInstance = L.map(embeddedMapId, mapOptions) - mapMarkerGroup.addTo(mapInstance) - candidateMarkerGroup.addTo(mapInstance) - // Add attribution - const cleanAttribution = sanitizeHtml(attribution, { - allowedTags: ["a"], - allowedAttributes: { - a: ["href", "target"], - }, - }) - L.tileLayer(tileURL, { - attribution: "© " + cleanAttribution, - zoom, - }).addTo(mapInstance) + try { + mapInstance = L.map(embeddedMapId, mapOptions) + mapMarkerGroup.addTo(mapInstance) + candidateMarkerGroup.addTo(mapInstance) - // Add click handler - mapInstance.on("click", handleMapClick) + // Add attribution + const cleanAttribution = sanitizeHtml(attribution, { + allowedTags: ["a"], + allowedAttributes: { + a: ["href", "target"], + }, + }) + L.tileLayer(tileURL, { + attribution: "© " + cleanAttribution, + zoom, + }).addTo(mapInstance) - // Reset view - resetView() + // Add click handler + mapInstance.on("click", handleMapClick) + + // Reset view + resetView() + } catch (e) { + console.log("There was a problem with the map", e) + } } const handleMapClick = e => {