gur111 icon

Workaround for changing pin locations

gur111 | PRO | 12/25/17 08:44:28 AM UTC | 0 ⭐ | 495 👁️ | Never ⏰ | []
JavaScript |

640 B

|

None

|

0 👍

/

0 👎

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