Files
openlayers/examples/extmap-main.html
andrewcoder002 7a74ba606a Test case of new functionality
Test case of new functionality that enables to switch map to another browser window and back
2021-11-02 00:21:09 +01:00

45 lines
1.3 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../build/ol.css" type="text/css">
<style>
.map {
height: 400px;
width: 600px;
}
</style>
<script src="../build/ol.js"></script>
<title>OpenLayers example</title>
</head>
<body>
<h2>External map window test case</h2>
<div id="map" class="map"></div>
<script src="extmap.js"></script>
<br/>
<input id="extMap" type="button" value="Open exteral map"></input>
<script>
const extMap = document.getElementById('extMap')
extMap.onclick = function(e){
extMap.disabled = true;
mapWindow = window.open('extmap-map.html','MapWindow','toolbar=0,location=0,menubar=0,width=800,height=600');
let smallMapDiv = document.getElementById("map");
smallMapDiv.style.height='0px';
mapWindow.onload = function() {
mapWindow.map = map;
let extMapDiv = mapWindow.document.getElementById("map");
map.setTarget(extMapDiv);
mapWindow.onbeforeunload = function () {
smallMapDiv.style.height='400px';
map.setTarget(smallMapDiv);
extMap.disabled = false;
};
}
}
</script>
</body>
</html>