Skip to content
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

Fix: issue 10611 add copy id feature to Panoramax #10697

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions css/60_photos.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ li.list-item-photos.active:after {
z-index: 50;
}

.photoviewer button.copy-id-btn {
border-radius: 0;
padding: 5px;
position: absolute;
left: 5px;
bottom: 5px;
z-index: 50;
}
.photoviewer .info{
border-radius: 5px;
padding: 6px;
position: absolute;
left: 25px;
bottom: 15px;
z-index: 100;
background-color: #ffffff;
color: #000;
}
.photoviewer button.set-photo-from-viewer {
border-radius: 0;
padding: 5px;
Expand Down
2 changes: 1 addition & 1 deletion modules/services/panoramax.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function loadTileDataToCache(data, tile, zoom) {
async function getImageData(collection_id, image_id){
const requestUrl = imageDataUrl.replace('{collectionId}', collection_id)
.replace('{itemId}', image_id);

const response = await fetch(requestUrl, { method: 'GET' });
if (!response.ok) {
throw new Error(response.status + ' ' + response.statusText);
Expand Down
70 changes: 69 additions & 1 deletion modules/ui/photoviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,74 @@ export function uiPhotoviewer(context) {
})
.append('div')
.call(svgIcon('#iD-icon-close'));
//add copy button
selection
.append('button')

.attr('class', 'copy-id-btn')

.attr('title', 'copy id') // Or a more specific title like "Copy Image ID"

.call(svgIcon('#iD-operation-paste'))

.on('click', function() {

// Determine the current service (Mapillary, Panoramax, etc.)

// add copy functionlity
let currentService;

if (services.mapillary.isViewerOpen()) {
currentService = 'mapillary';
} else if (services.panoramax.isViewerOpen()) {
currentService = 'panoramax';
}
// Add more conditions for other services if needed

if (currentService) {
const service = services[currentService];
const activeImage = service.getActiveImage();

if (activeImage && activeImage.id) {
navigator.clipboard.writeText(activeImage.id)
.then(() => {
// display a success message

const info=document.querySelector('#info')

info.style.display="block"

// Remove the tooltip after a short delay

setTimeout(() => {

info.style.display="none"

}, 1500); // Remove after 1.5 seconds

})
.catch(err => {
console.error('Failed to copy: ', err);
});
} else {
console.warn('No active image or ID available.');
}
} else {
console.warn('No active image service detected.');
}
});

selection

.append('span')

.attr('class','info')

.style('display', 'none')

.attr('id','info')

.text("Copied!")

function preventDefault(d3_event) {
d3_event.preventDefault();
Expand Down Expand Up @@ -73,7 +141,7 @@ export function uiPhotoviewer(context) {
setPhotoFromViewerButton();
});


function setPhotoFromViewerButton() {
if (services.mapillary.isViewerOpen()) {
if (context.mode().id !== 'select' || !(layerStatus('mapillary') && getServiceId() === 'mapillary')) {
Expand Down