Quickstart Guide

To start using the leaflet-rails gem, follow the steps below (assuming you use the default asset pipeline):

First, add the following code to your Gemfile.

gem'leaflet-rails'

Then, run bundle install from within your project to download the necessary files. Following that, open your application-wide CSS file (app/assets/stylesheets/application.css) and add the following line as a comment:

= require leaflet

After that, open your application-wide Javascript file (typically app/assets/javascripts/application.js) and add the following line before requiring files which depend on Leaflet:

= require leaflet

At this point, you may skip the first two steps of the Leaflet Quick Start guide and start at the third step (adding the map div to a view).

Version Parity

leaflet-rails tries to keep version parity with leaflet.js. However, this isn't possible in all cases. Discrepancies have been noted below.

leaflet-rails

leaflet.js

Reason

0.7.4

0.7.3

Requested in #33 because of large gap between master and rubygems.org.

0.7.5

0.7.5

leaflet.js 0.7.4 was reverted.

0.7.6

----

Skipped to sync with upstream.

0.7.7

0.7.7

Sync version numbers with upstream.

Helpers

To get you up and running quickly, you can also use the gem's helper. To get started, add the following lines to a file called leaflet.rb in config/initializers:

Leaflet.tile_layer="http://{s}.tile.cloudmade.com/YOUR-CLOUDMADE-API-KEY/997/256/{z}/{x}/{y}.png"# You can also use any other tile layer here if you don't want to use Cloudmade - see http://leafletjs.com/reference.html#tilelayer for more
Leaflet.attribution="Your attribution statement"Leaflet.max_zoom=18

If you are using a tile layer which requires non-default subdomains such as MapQuest-OSM Tiles, you can set the subdomains like this: