Adding file drop capability to import GPX files.

This commit is contained in:
Eric van der Vlist 2023-03-17 19:57:22 +01:00
parent 9b9bba1609
commit 41c81fca1b
1 changed files with 28 additions and 1 deletions

View File

@ -130,6 +130,28 @@ const Map: Component = () => {
});
}
const dropHandler = (event: any) => {
event.preventDefault();
console.log({
caller: 'Map / dropHandler',
event,
files: event.dataTransfer.files,
});
importUrls(event.dataTransfer.files);
};
const dragOverHandler = (event: any) => {
event.preventDefault();
console.log({ caller: 'Map / dragOverHandler', event });
};
// const dragStartHandler = (event: any) => {
// event.preventDefault();
// event.dataTransfer.effectAllowed = 'all';
// event.dataTransfer.dropEffect = 'move';
// console.log({ caller: 'Map / dragStartHandler', event });
// };
if (
params.lat === '0' &&
params.lon === '0' &&
@ -313,7 +335,12 @@ const Map: Component = () => {
return (
//<OsmFetch map={getMap} />
// @ts-ignore
<div class='ol-map' ref={target}>
<div
class='ol-map'
ref={target}
ondrop={dropHandler}
ondragover={dragOverHandler}
>
<Updater />
<Invitation />
<Overlays map={getMap} />