Skip to content

Commit

Permalink
add option to download the osmPatch file from the map
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yle committed Jun 25, 2024
1 parent 4c63f76 commit 56007e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pages/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Fragment, useEffect, useState } from 'react';
import { MapContainer, Polygon, Tooltip } from 'react-leaflet';
import type { LeafletMouseEvent } from 'leaflet';
import { uniqBy } from '../../helpers';
import { downloadFile } from '../upload/util';
import { Layers } from './Layers';
import { MapErrorBoundary } from './MapErrorBoundary';

Expand Down Expand Up @@ -57,6 +58,11 @@ function returnToRapiD(id: string, locked: Locked) {
window.close();
}

async function downloadLayer(layer: Layer) {
const blob = await fetch(layer.url).then((r) => r.blob());
downloadFile(blob, layer.url.split('/').at(-1)!);
}

// Return a deeper red for changesets with more changes
function getColor(d: number) {
return d > 1000
Expand Down Expand Up @@ -216,6 +222,7 @@ export const Map: React.FC = () => {
eventHandlers={{
click: () => {
if (fromRapiD) returnToRapiD(x.id, data[1][x.id]);
else downloadLayer(x);
},
contextmenu: () =>
setLayersToHide((existing) => [...existing, x.id]),
Expand Down

0 comments on commit 56007e1

Please sign in to comment.