Leaflet

A Modern, Lightweight Open-Source JavaScript Library for Interactive Maps by CloudMade

Leaflet is a modern, lightweight BSD-licensed JavaScript library for making tile-based interactive maps for both desktop and mobile web browsers, developed by CloudMade to form the core of its next generation JavaScript API.

It is built from the ground up to work efficiently and smoothly on both platforms, utilizing cutting-edge technologies included in HTML5. Its top priorities are usability, performance, small size, A-grade browser support, flexibility and easy to use API. The OOP-based code of the library is designed to be modular, extensible and very easy to understand. Find out more on the features page.

Basic usage example

Here we create a map with a CloudMade tile layer, add a marker and bind a popup with some text to it:

// create a CloudMade tile layer
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/YOUR-API-KEY/997/256/{z}/{x}/{y}.png',
	cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
	cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),

// initialize the map on the "map" div
var map = new L.Map('map');

// set the map view to a given center and zoom and add the CloudMade layer
map.setView(new L.LatLng(51.505, -0.09), 13).addLayer(cloudmade);

// create a marker in the given location and add it to the map
var marker = new L.Marker(new L.LatLng(51.5, -0.09));
map.addLayer(marker);

// attach a given HTML content to the marker and immediately open it
marker.bindPopup("A pretty CSS3 popup.<br />Easily customizable.").openPopup();

Check out the examples section for more examples, or head straight to the documentation.

Contributing to Leaflet

The project is hosted on GitHub, waiting for your contributions — just send your pull requests to Vladimir Agafonkin (Leaflet maintainer). Let's make the best library for maps that can possibly exist!

You can also help the project a lot by reporting bugs and discussing features on the issues page or tweeting to @LeafletJS.


© 2011 CloudMade. Map data © 2011 OpenStreetMap contributors, CC-BY-SA.

Fork me on GitHub