@Greg Yes, I used the 1600px resolution image at that address because it’s only 166kb more for a sharper image. I arrived at the coordinates by using a scaling script.
document.addEventListener("DOMContentLoaded", function() {
// Original and new dimensions
const originalWidth = 730;
const originalHeight = 894;
const newWidth = 1600;
const newHeight = 1956;
// Calculate scale factors for width and height
const scaleX = newWidth / originalWidth;
const scaleY = newHeight / originalHeight;
// Find all area elements in the map and adjust their coordinates
document.querySelectorAll('map[name="acadia_map_730px"] area').forEach(area => {
// Get current coordinates and convert them into an array of numbers
const coords = area.getAttribute('coords').split(',').map(Number);
// Scale the coordinates
const scaledCoords = coords.map((coord, index) => {
// Apply scaleX to x coordinates (even indices) and scaleY to y coordinates (odd indices)
return Math.round(coord * (index % 2 === 0 ? scaleX : scaleY));
});
// Update the area element with the new scaled coordinates
area.setAttribute('coords', scaledCoords.join(','));
});
});
It’s not relevant, but I got the code in the browser I needed for the 1600px size, and then I swapped out the map info and updated the image information also. I used the original responsive map script provided by @kuligaposten.
I also fine-tuned some of the coordinates using this online site by uploading the 1600px image and obtaining new positions for about 10 or so areas: https://imagemap.org/
If you open up my example in a browser and then view the source code, everything for the image and map is right there to copy from.
Then add the script.
You should end up with this when you are done.
<!-- Make sure to edit img for updated settings
-->
<div class="column_center_map">
<img src="images/maps/acadia-mdi-1600px.png" alt="Map of Mount Desert Island and Acadia National Park" usemap="#acadia_map_1600px" id="responsive-image" class="img-responsive map_shadow">
<map name="acadia_map_1600px" id="acadia_map_1600px">
<area shape="rect" alt="Otter Cove" coords="1337,1284,1539,1335" href="otter-cove-photos-01.html" title="Otter Cove">
<!-- All the other areas -->
<area shape="rect" alt="Ellsworth, Maine" coords="107,23,317,76" href="ellsworth-maine.html" title="Ellsworth, Maine">
</map>
</div>
<!--
add map.js script (kuligaposten)
-->
<script src="ScriptLibrary/map.js"></script>
<!--
document.addEventListener(
'DOMContentLoaded',
function () {
let originalWidth =
document.getElementById('responsive-image').naturalWidth;
let originalHeight =
document.getElementById('responsive-image').naturalHeight;
function adjustImageMap() {
const img = document.getElementById('responsive-image');
const areas = img.parentNode.getElementsByTagName('area');
const imgWidth = img.clientWidth;
const imgHeight = img.clientHeight;
const scaleFactor = Math.min(
imgWidth / originalWidth,
imgHeight / originalHeight
);
originalWidth = img.clientWidth;
originalHeight = img.clientHeight;
for (let i = 0; i < areas.length; i++) {
let coords = areas[i].coords.split(',');
for (let j = 0; j < coords.length; j++) {
coords[j] = Math.round(coords[j] * scaleFactor);
}
areas[i].coords = coords.join(',');
}
}
window.addEventListener('resize', adjustImageMap);
window.addEventListener('DOMContentLoaded', adjustImageMap);
},
false
);
-->