Skip to content

Commit 04ad79a

Browse files
committed
fix example img download in chrome/safari
1 parent 76f6d23 commit 04ad79a

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

packages/clients/diplan/example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h2>Informationen aus Kartenklient</h2>
3838
</tr>
3939
<tr>
4040
<td><code>plugin/export/exportedMap</code></td>
41-
<td><img onclick="window.open(this.src, '_blank');" id="subscribed-export" /></td>
41+
<td><a id="subscribed-export-a" download="polar_screenshot.png" href=""><img id="subscribed-export-img" /></a></td>
4242
<td>Screenshot des aktuellen Kartenausschnitts. Produzierbar durch Klick auf den unteren linken "Export"-Button.</td>
4343
</tr>
4444
<tr>

packages/clients/diplan/example/prod-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h2>Informationen aus Kartenklient</h2>
3838
</tr>
3939
<tr>
4040
<td><code>plugin/export/exportedMap</code></td>
41-
<td><img onclick="window.open(this.src, '_blank');" id="subscribed-export" /></td>
41+
<td><a id="subscribed-export-a" download="polar_screenshot.png" href=""><img id="subscribed-export-img" /></a></td>
4242
<td>Screenshot des aktuellen Kartenausschnitts. Produzierbar durch Klick auf den unteren linken "Export"-Button.</td>
4343
</tr>
4444
<tr>

packages/clients/diplan/example/setup.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export default (client, layerConf, config) => {
4242

4343
const htmlZoom = document.getElementById('subscribed-zoom')
4444
const htmlGfi = document.getElementById('subscribed-gfi')
45-
const htmlExport = document.getElementById('subscribed-export')
45+
const htmlExportA = document.getElementById('subscribed-export-a')
46+
const htmlExportImg = document.getElementById('subscribed-export-img')
4647

4748
mapInstance.subscribe(
4849
'plugin/zoom/zoomLevel',
@@ -52,9 +53,17 @@ export default (client, layerConf, config) => {
5253
'plugin/gfi/featureInformation',
5354
(v) => (htmlGfi.innerHTML = JSON.stringify(v, null, 2))
5455
)
55-
mapInstance.subscribe('plugin/export/exportedMap', (screenshot) =>
56-
htmlExport.setAttribute('src', screenshot)
57-
)
56+
mapInstance.subscribe('plugin/export/exportedMap', (screenshot) => {
57+
htmlExportImg.setAttribute('src', screenshot)
58+
if (navigator.userAgent.toLowerCase().includes('firefox')) {
59+
htmlExportImg.onclick = function () {
60+
window.open(this.src, '_blank')
61+
}
62+
htmlExportA.onclick = () => false
63+
} else {
64+
htmlExportA.setAttribute('href', screenshot)
65+
}
66+
})
5867

5968
window.mapInstance = mapInstance
6069
})

0 commit comments

Comments
 (0)