<!DOCTYPE html>
<html>
<head>
<title>Custom Overview Map</title>
<link rel="stylesheet" href="https://openlayers.org/en/v5.3.0/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<style>
ol-custom-overviewmap,
ol-custom-overviewmap.ol-uncollapsible {
bottom: auto;
left: auto;
right: 0;
top: 0;
}
ol-custom-overviewmap:not(.ol-collapsed) {
border: 1px solid black;
}
ol-custom-overviewmap .ol-overviewmap-map {
border: none;
width: 300px;
}
ol-custom-overviewmap .ol-overviewmap-box {
border: 2px solid red;
}
ol-custom-overviewmap:not(.ol-collapsed) button{
bottom: auto;
left: auto;
right: 1px;
top: 1px;
}
ol-rotate {
top: 170px;
right: 0;
}
</style>
<script src="https://openlayers.org/en/v5.3.0/build/ol.js" type="text/javascript"></script>
</head>
<body>
<div id="map"></div>
<script>
var map = new ol.Map({
target: 'map',
layers: [
// 加载Open Street Map
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults().extend([
new ol.control.OverviewMap()
// 创建一个鹰眼控件,并添加到地图的默认控件中
]),
view: new ol.View({
center: [500000, 6000000],
zoom: 7
})
});
</script>
</body>
</html>