From 04ad79a37f19843068e8d093597406f65e6727fa Mon Sep 17 00:00:00 2001 From: Dennis Sen Date: Tue, 11 Feb 2025 06:55:29 +0100 Subject: [PATCH] fix example img download in chrome/safari --- packages/clients/diplan/example/index.html | 2 +- .../clients/diplan/example/prod-example.html | 2 +- packages/clients/diplan/example/setup.js | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/clients/diplan/example/index.html b/packages/clients/diplan/example/index.html index 2152f9501..da825af18 100644 --- a/packages/clients/diplan/example/index.html +++ b/packages/clients/diplan/example/index.html @@ -38,7 +38,7 @@

Informationen aus Kartenklient

plugin/export/exportedMap - + Screenshot des aktuellen Kartenausschnitts. Produzierbar durch Klick auf den unteren linken "Export"-Button. diff --git a/packages/clients/diplan/example/prod-example.html b/packages/clients/diplan/example/prod-example.html index c6bb7ef2a..8f01efd3f 100644 --- a/packages/clients/diplan/example/prod-example.html +++ b/packages/clients/diplan/example/prod-example.html @@ -38,7 +38,7 @@

Informationen aus Kartenklient

plugin/export/exportedMap - + Screenshot des aktuellen Kartenausschnitts. Produzierbar durch Klick auf den unteren linken "Export"-Button. diff --git a/packages/clients/diplan/example/setup.js b/packages/clients/diplan/example/setup.js index ab6f442b8..edbb65104 100644 --- a/packages/clients/diplan/example/setup.js +++ b/packages/clients/diplan/example/setup.js @@ -42,7 +42,8 @@ export default (client, layerConf, config) => { const htmlZoom = document.getElementById('subscribed-zoom') const htmlGfi = document.getElementById('subscribed-gfi') - const htmlExport = document.getElementById('subscribed-export') + const htmlExportA = document.getElementById('subscribed-export-a') + const htmlExportImg = document.getElementById('subscribed-export-img') mapInstance.subscribe( 'plugin/zoom/zoomLevel', @@ -52,9 +53,17 @@ export default (client, layerConf, config) => { 'plugin/gfi/featureInformation', (v) => (htmlGfi.innerHTML = JSON.stringify(v, null, 2)) ) - mapInstance.subscribe('plugin/export/exportedMap', (screenshot) => - htmlExport.setAttribute('src', screenshot) - ) + mapInstance.subscribe('plugin/export/exportedMap', (screenshot) => { + htmlExportImg.setAttribute('src', screenshot) + if (navigator.userAgent.toLowerCase().includes('firefox')) { + htmlExportImg.onclick = function () { + window.open(this.src, '_blank') + } + htmlExportA.onclick = () => false + } else { + htmlExportA.setAttribute('href', screenshot) + } + }) window.mapInstance = mapInstance })