-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tooltip Feature for ImageOverlays #1321
Changes from 69 commits
18bc466
4ced8eb
c5beb1e
d755efa
16aacf1
f71ad84
802486a
75e8fe3
dcc2ea0
4f09c61
971ce75
2961a5f
67bb362
1d8fe70
bde1749
82d297e
dd8cf1f
72e37ad
4677c2c
383c072
1b3f785
6e1b5f3
dfc9ee2
88cf6ca
603bbb9
1fc0c1c
fbf910a
89772c5
fa51b78
97e2a89
0c47683
15390ae
ed68ed6
a2eac1b
4b11af9
36a8bc9
82fe23d
ae7160c
8f3d21f
7e57f3e
9aec26e
1fcea57
413267e
7516502
4d7663a
20dd153
7d9c8c7
c5de57f
ef2fb6e
7b00604
a0cc2d1
63953c6
e6d4389
13e04f9
f79faf8
24c08af
0afd5d7
96ad807
0a0807d
59938e1
bd63422
9537359
0c1cd18
9ea2d35
a91b0e2
d1f6d0a
c9d0a13
55d3997
961cd01
e320171
079ec14
f9cfe2e
8b11891
6d8f547
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ function extractKey() { | |
else if (input.value.includes('http://')) { | ||
getUrl = input.value.replace('http:', 'https:'); | ||
input.value = getUrl; | ||
console.log('input', input.value); | ||
showImages(getUrl); | ||
} | ||
else | ||
|
@@ -60,7 +59,6 @@ function extractKey() { | |
let imageCount = 0; | ||
let fetchedFrom; | ||
|
||
|
||
const renderImages = (fullResImages, url) => { | ||
fullResImages.forEach((file) => { | ||
const imageRow = document.createElement('div'); | ||
|
@@ -110,13 +108,19 @@ const renderThumbnails = (thumbnails = [], url, fullResImgs) => { | |
placeButton.innerHTML = 'Place'; | ||
placeButton.setAttribute('title', 'Place image on map'); | ||
|
||
// store the full-resolution image URL in a "data-original" attribute | ||
image.setAttribute('data-original', `${url.replace('metadata', 'download')}/${thumbnails ? file.original : file.name}`); | ||
image.src = `${url.replace('metadata', 'download')}/${file.name}`; | ||
imageRow.classList.add('col-4', 'd-flex', 'flex-column', 'p-2', 'align-items-center'); | ||
imageRow.append(image, placeButton, fileName); | ||
// store the full-resolution image URL in a "data-original" attribute | ||
image.setAttribute('data-original', `${url.replace('metadata', 'download')}/${thumbnails ? file.original : file.name}`); | ||
image.src = `${url.replace('metadata', 'download')}/${file.name}`; | ||
imageRow.classList.add('col-4', 'd-flex', 'flex-column', 'p-2', 'align-items-center'); | ||
imageRow.append(image, placeButton, fileName); | ||
imageContainer.appendChild(imageRow); | ||
imageContainer.setAttribute('class', 'row'); | ||
imageContainer.setAttribute('class', 'row'); | ||
imageCount++; | ||
}); | ||
}; | ||
|
@@ -148,7 +152,6 @@ function showImages(getUrl) { | |
}) | ||
.catch((error) => { | ||
jywarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
responseText.innerHTML = 'Uh-oh! Something\'s not right with the link provided!'; | ||
jywarren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
console.log(error); | ||
}) | ||
.finally(() => { | ||
bootstrap.Modal.getInstance(welcomeModal).hide(); | ||
|
@@ -172,10 +175,23 @@ tileMap.addEventListener('click', (event) => { | |
bootstrap.Offcanvas.getInstance(sidebar).hide(); | ||
}); | ||
|
||
function getImageName(imageURL) { | ||
startIndex = imageURL.lastIndexOf('/') + 1; | ||
endIndex = imageURL.lastIndexOf('.'); | ||
const imageName = imageURL.substring(startIndex, endIndex); | ||
|
||
return imageName; | ||
} | ||
|
||
document.addEventListener('click', (event) => { | ||
if (event.target.classList.contains('place-button')) { | ||
const imageURL = event.target.previousElementSibling.dataset.original; | ||
const image = L.distortableImageOverlay(imageURL); | ||
const imageURL = event.target.previousElementSibling.src; | ||
const imageTooltipText = getImageName(imageURL); | ||
|
||
const image = L.distortableImageOverlay( | ||
imageURL, | ||
{tooltipText: imageTooltipText} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we used the filename, we could just split There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice.... I'll give this a shot. Many thanks! |
||
); | ||
map.imgGroup.addLayer(image); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, is this something we need in the shared .gitignore or just for you? I'm ok either way i guess, I'm just thinking it's not 100% necessary to share.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! yeah... I'd would remove these fast, thanks for spotting them @jywarren.