LeafletJS is a widely used open source JavaScript library used to build web mapping applications. First released in 2011, it supports most mobile and desktop platforms, supporting HTML5 and CSS3.
# Leaflet and Openstreetmap
- Example with OpenStreetMap layer
- as an eBook free to download or to read online
- Examples, but with MapBox layers as default
A typical use of Leaflet involves binding a Leaflet "map" element to an HTML element such as a div. Layers and markers are then added to the map element. The Leaflet library itself is accessible through the variable L.
// create a map in the "map" div // set the view to a given place and zoom var map = L.map('map').setView([51.505, -0.09], 13); // add an OpenStreetMap tile layer L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(map);