Get started with leaflet-minimap CDN
BSD-2-Clause licensed
Leaflet.js plugin: Leaflet-minimap adds small map thumbnail as overlay for navigation.
Tags:- maps
- leaflet
- client
- minimap
Stable version
Copied!
How to start using leaflet-minimap CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with leaflet-minimap CDN - cdnhub.io</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.7.1/leaflet.css"/>
<script src="https://cdn.jsdelivr.net/leaflet/1.7.1/leaflet.js"></script>
<script src="https://cdn.cdnhub.io/leaflet-minimap/3.6.1/Control.MiniMap.min.js"></script>
<style>
#mapid { height: 400px; width: 100%; }
#minimap { position: absolute; top: 0; right: 0; height: 200px; width: 200px; }
</style>
</head>
<body>
<div id="mapid"></div>
<div id="minimap"></div>
<script>
const map = L.map('mapid').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 19
}).addTo(map);
L.control.minimap({
position: 'bottomright',
collapsed: false,
overlayOpacity: 0.5,
target: map
}).addTo(map);
const minimap = map.getControl('minimap');
minimap.on('minimapmoveend', function() {
map.setView(minimap.getCenter());
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!