You have to change your image path:
cv.drawImage({
layer: true,
source: 'https://res.cloudinary.com/benbruce/image/upload/v1578505333/camera' + (i+1) +'.png',
x: 559,
y: y,
width: size,
height: size,
fromCenter: false,
draggable: true,
drag: onDrag,
dragstop: onDragEnd
});
And before starting the second loop we have to set the variable finish to false again:
function onDragEnd(layer) {
console.log('dragend');
// x and y are properties of the layer, i. e. the circle
const x = layer.x + diameter, y = layer.y + diameter;
const i = Math.floor(y / hRect), j = Math.floor(x / wRect);
// get the map layer the mouse is currently over
const themaplayer = maplayers[i][j];
console.log(x, y, i, j);
if (isIntersect(layer, themaplayer, themap[i][j])) {
themaplayer.fillStyle = 'lightsalmon';
}
let finish = false;
for (let i2 = i; i2 < themap.length && !finish; i2++) {
if (themap[i2][j] == 0) {
const themaplayer = maplayers[i2][j];
themaplayer.fillStyle = 'lightsalmon';
} else {
finish = true;
}
}
finish = false; // <-- has to be set to false again
for (let i2 = i; i2 >= 0 && !finish; i2--) {
if (themap[i2][j] == 0) {
const themaplayer = maplayers[i2][j];
themaplayer.fillStyle = 'lightsalmon';
} else {
finish = true;
}
}
cv.drawLayers();
}