leaflet
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Leaflet is a leading open-source JavaScript library for creating mobile-friendly interactive maps. It was built with simplicity, performance, and usability in mind. Despite its light footprint of roughly 39 KB of gzipped JS and 4 KB of gzipped CSS code, it comes with a rich set of mapping features suited for most developers' needs. Leaflet operates effectively across all key desktop and mobile platforms, leveraging HTML5 and CSS3 on modern browsers but also maintaining accessibility on older ones. It offers a broad range of extensions via numerous plugins, a user-friendly and well-documented API, and an easily readable source code, which welcomes contributions from the developer community.
Using Leaflet in your JavaScript project is straightforward. First, you'll need to include the Leaflet CSS and JS files in your HTML file.
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
Then, you can begin to create maps in your application. For instance, you might initialize a map focused on a specific geographical location in the following way:
let map = L.map('map').setView([51.505, -0.09], 13);
Next, you can add a tile layer to the map from an open-source provider like OpenStreetMap:
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Β© OpenStreetMap contributors'
}).addTo(map);
Lastly, you can add interactive features like markers, circles, and polygons with popup text:
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A marker added to the map.')
.openPopup();
The detailed Leaflet documentation is available at http://leafletjs.com/reference.html, offering a comprehensive reference of the API. For more info, additional documentations, and tutorials, you can check out the official website. If you wish to contribute to Leaflet, visit their GitHub repository or read their contribution guide.