Get started with leaflet CDN

BSD-2-Clause licensed

Leaflet: Lightweight open-source map, location service library.

Tags:
  • maps
  • mobile

Stable version

Copied!

How to start using leaflet CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with leaflet CDN - cdnhub.io</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.css"/>
    <script src="https://cdn.cdnhub.io/leaflet/1.9.4/leaflet.js"></script>
</head>
<body>
    <div id="mapid" style="height: 400px; width: 100%;"></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: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
            maxZoom: 19
        }).addTo(map);

        L.marker([51.5, -0.09])
            .addTo(map)
            .bindPopup('A marker popup!')
            .openPopup();
    </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions