const
bdy = document.body,
svg = document.getElementById('svg'),
bkg = document.getElementById('background'),
eye = document.getElementById('eye'),
frm = document.getElementById('frame')
let
eyeW = 0.35,
eyeH = 0.75,
mousednX = 0,
mousednY = 0
// position maps on load
//
window.addEventListener('load', position)
function position(){
const
box = svg.getBoundingClientRect()
svg.style.left = -(box.width - innerWidth) / 2 + 'px'
svg.style.top = -(box.height - innerHeight) / 2 + 'px'
const
x = -(svg.getBoundingClientRect().left) + innerWidth * (1 - eyeW) / 2,
y = -(svg.getBoundingClientRect().top) + innerHeight * (1 - eyeH) / 2
eye.setAttribute('width', innerWidth * eyeW)
eye.setAttribute('height', innerHeight * eyeH)
eye.setAttribute('x', x)
eye.setAttribute('y', y)
frm.setAttribute('width', innerWidth * eyeW)
frm.setAttribute('height', innerHeight * eyeH)
frm.setAttribute('x', x)
frm.setAttribute('y', y)
}
// drag functionality to explore map
//
bdy.addEventListener('mousedown', mousedown)
window.addEventListener('mouseup', mouseup)
function mousedown(e){
e.preventDefault()
mousednX = e.clientX
mousednY = e.clientY
bdy.addEventListener('mousemove', mousemove)
}
function mouseup(){
bdy.removeEventListener('mousemove', mousemove)
}
function mousemove(e){
adjustX = e.clientX - mousednX
adjustY = e.clientY - mousednY
if (svg.getBoundingClientRect().left + adjustX < 0 && svg.getBoundingClientRect().right + adjustX > innerWidth){
svg.style.left = svg.getBoundingClientRect().left + adjustX + 'px'
} else if (svg.getBoundingClientRect().left + adjustX >= 0){
svg.style.left = 0 + 'px'
} else {
svg.style.left = -(svg.getBoundingClientRect().width - innerWidth)
}
if (svg.getBoundingClientRect().top + adjustY < 0 && svg.getBoundingClientRect().bottom + adjustY > innerHeight){
svg.style.top = svg.getBoundingClientRect().top + adjustY + 'px'
} else if (svg.getBoundingClientRect().top + adjustY >= 0){
svg.style.top = 0 + 'px'
} else {
svg.style.top = -(svg.getBoundingClientRect().height - innerHeight)
}
mousednX = e.clientX
mousednY = e.clientY
}
// center eye on cursor position
//
bdy.addEventListener('mousemove', moveEye)
function moveEye(e){
const
x = -(svg.getBoundingClientRect().left) + e.clientX - eyeW * innerWidth / 2,
y = -(svg.getBoundingClientRect().top) + e.clientY - eyeH * innerHeight / 2
eye.setAttribute('x', x)
eye.setAttribute('y', y)
frm.setAttribute('x', x)
frm.setAttribute('y', y)
}
body {
width: 100vw;
height: 100vh;
overflow: hidden;
margin: 0;
}
#svg {
width: 6144px;
height: 4608px;
position: absolute;
left: -3072px;
top: -2304px;
}
#eye {
fill: #FFF;
}
#map {
width: 6144px;
height: 4608px;
mask: url('#mask');
}
<svg id='svg' viewBox='0 0 6144 4608' version='1.1'>
<filter id="contrast">
<feComponentTransfer>
<feFuncR type="linear" slope="0.4" intercept="0.2"/>
<feFuncG type="linear" slope="0.4" intercept="0.2"/>
<feFuncB type="linear" slope="0.4" intercept="0.2"/>
</feComponentTransfer>
</filter>
<mask id='mask'>
<g filter="url(#contrast)">
<rect id='background' x='0' y='0' width='6144' height='4608' fill="#000"/>
<rect id='eye' x='0' y='0' width='0' height='0' />
<image id='frame' xlink:href='https://newvitruvian.com/images/speckled-vector-distress.png' x='0' y='0' width='0' height='0' preserveAspectRatio='none'/>
</g>
</mask>
<image id='map' xlink:href='https://i.postimg.cc/hvH4yn2Q/map.jpg' x='0' y='0' width='6144' height='4608' mask="url(#myMask)"/>
</svg>