function relocateImg(){
// Get the pin object
let pin = document.images[4]; // TODO: You need to loop using different pins on this variable
// Get the page object
let img = document.getElementById("image_annotation");
// The original page width to calculate relative modifier
const pageOriginalWidth = 905;
// Get original pin location
const originalPX = pin.getAttribute("data-x");
const originalPY = pin.getAttribute("data-y");
// Calculate modifier
let mod = pageOriginalWidth/img.width;
// Set the location of the pin to be relative to the page's size
pin.style.left = originalPY/mod+"px"
pin.style.top = originalPX/mod+"px"
}
Comments