在JavaScript领域中,用于创建小地图(也称为迷你地图或缩略图)的插件众多,它们各自具有独特的特点和优势。以下是一些流行的JavaScript小地图插件及其相关信息:
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Mini Map Example</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<style>
#map { height: 400px; }
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map('map').setView([39.90923, 116.397428], 12);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map);
L.marker([39.90923, 116.397428]).addTo(map)
.bindPopup('<div class="custom-popup"><h3>天安门广场</h3><p>我的标记我做主!</p><button onclick="alert(\'Hi\')">点我试试</button></div>')
.openPopup();
</script>
</body>
</html>
以上插件均可以通过CDN链接引入到你的项目中,具体使用方法请参考各插件的官方文档。
领取专属 10元无门槛券
手把手带您无忧上云