I wrote some simple function to restore all map points on each event. try it
function mapRebuild(scaleValue) { var map = $("#imgmap"); // select your map or for all map you can choose $("map").each(function() { map = $(this);.....}) map.find("area").each(function() { // select all areas var coords = $(this).attr("coords"); // extract coords coords = coords.split(","); // split to array var scaledCoords = ""; for (var coord in coords) { // rebuild all coords with scaleValue scaledCoords += Math.floor(coords[coord] * scaleValue) + ","; } scaledCoords = scaledCoords.slice(0, -1); // last coma delete $(this).attr("coords", scaledCoords); // set new coords }); }
scaleValue can be calculated as oldWindowWidth / newWindowWidth. Of course, you need to keep the value of oldWindowWidth when resizing the window. Maybe my decision is not on time, but I hope this is useful to someone.
Viktor Sanzharevskyy
source share