Skip to content

Commit db9231d

Browse files
committed
Fix Issue #17 repeated rescaling of image map.
Repeated scaling of image map will after a while make the image map coordinates diverge from the location of the airport on the map. To fix this the coordinates of the image map will be cached and used for calculating the new image map coordinates when scaling is applie. This patch also now resizes the airport locator circle so it is not a tiny circle when zoomed to 200%.
1 parent cdc21ec commit db9231d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

common/scripts/map_actions.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function locateAirport(list) {
221221
refreshCanvas();
222222
x = parseInt(coords[0]);
223223
y = parseInt(coords[1]);
224-
drawHighlight(context,x,y,radius);
224+
drawHighlight(context,x,y,radius * properties.zoom);
225225

226226
// Make the airport the focus
227227
window.scrollTo(x-window.innerWidth/2,y-window.innerHeight/2);
@@ -538,14 +538,21 @@ function selectVisibility(list) {
538538
refreshCanvas();
539539
}
540540

541+
var hotspots;
542+
function storeMapCoordinates() {
543+
var imgMap = document.getElementById("imgMap");
544+
hotspots = [];
545+
for (area of imgMap.children) hotspots.push(area);
546+
}
541547

542548
// Scale the image map coordinates to match the airport overlay image
543549
function scaleMap(scale) {
544550
var imageMap = document.getElementById("imgMap");
545551
var areas = imageMap.children;
552+
i = 0;
546553
for (area of areas) {
547-
area.coordArr = area.coords.split(',');
548-
area.coords = area.coordArr.map(coord => Math.round(coord * scale)).join(',');
554+
var coordArr = hotspots[i++].coords.split(',');
555+
area.coords = coordArr.map(coord => Math.round(coord * scale)).join(',');
549556
if (area.alt == "Legend") properties.legend = area.coords;
550557
if (area.alt == "Bullseye") bullseye.coords = area.coords;
551558
}
@@ -1641,7 +1648,9 @@ window.onload = function(e) {
16411648

16421649
// Adjust map to used scale
16431650
// Safari will slow beyond 3840 canvas size
1651+
storeMapCoordinates();
16441652
scaleMap(3840/4096);
1653+
storeMapCoordinates();
16451654

16461655
// Setup the Layers to be rendered on the main canvas
16471656
setupLayer(layer.mission, canvas.width, canvas.height );

0 commit comments

Comments
 (0)