
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/leaflet/1.6.0/leaflet.css">
<script src="https://cdn.bootcdn.net/ajax/libs/leaflet/1.6.0/leaflet.js"></script>
<title>Leaflet Map</title>
<style>
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map(document.getElementById("map"), {
center: L.latLng(39.91589994226363, 116.39079093933107),
zoom: 16,
minZoom: 10,
maxZoom: 20
});
var tileUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
L.tileLayer(tileUrl, {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
minZoom: 10,
maxZoom: 20
}).addTo(map);
var icon = L.icon({
iconUrl: 'https://img-home.csdnimg.cn/images/20210806113404.gif',
className: 'icon'
});
var marker = L.marker(
[39.920598, 116.390576],
{
draggable: true,
icon: icon,
},
).addTo(map);
marker.setLatLng([39.920598, 116.390576]);
marker.bindPopup('气泡内容', {
offset: [0, -16