[openstreetmap/openstreetmap-website] Image download with user feedback (PR #6192)

mmd notifications at github.com
Sat Jul 19 14:23:17 UTC 2025


@mmd-osm commented on this pull request.



> @@ -7,8 +7,33 @@ L.OSM.share = function (options) {
         });
 
   function init(map, $ui) {
-    // Link / Embed
+    $("#export-image").on("turbo:submit-end", function (event) {
+      if (event.detail.success) {
+        event.detail.fetchResponse.response.blob().then((blob) => {
+          const url = URL.createObjectURL(blob);
+          const a = document.createElement("a");
+          a.href = url;
+          const contentType = blob.type;
+          let extension = "bin";
+          if (contentType === "image/png") extension = "png";
+          else if (contentType === "image/jpeg") extension = "jpg";
+          else if (contentType === "image/svg+xml") extension = "svg";
+          else if (contentType === "image/webp") extension = "webp";
+          else if (contentType === "application/pdf") extension = "pdf";
+          a.download = `map.${extension}`;

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6192#discussion_r2217331685
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6192/review/3035384592 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250719/0bd63adf/attachment.htm>


More information about the rails-dev mailing list