https://github.com/Leaflet/Leaflet.draw is vector drawing and editing plugin for Leaflet. This gem adds it to your Rails application.
Add this line to your application's Gemfile:
gem 'leaflet-draw-rails'
And execute:
$ bundle install
Then require leaflet.draw
into your application.js
manifest, which is usually located in app/assets/javascripts
//= require leaflet.draw
After that, require leaflet.draw
into your application.css
manifest, which is usually located in app/assets/stylesheets
*= require leaflet.draw
To alleviate testing problems, there are helper methods accessible in RSpec or Cucumber features. capybara
and selenium-webdriver
are required.
leaflet_draw_marker([ 200, 200 ]).on find('#map')
leaflet_draw_polyline([ [ 200, 200 ], [ 300, 300 ] ]).on find('#map')
leaflet_draw_polygon([ [ 200, 200 ], [ 300, 300 ], [ 300, 200 ] ]).on find('#map')
leaflet_draw_rectangle([ [ 200, 200 ], [ 300, 300 ] ]).on find('#map')
leaflet_draw_circle([ [ 200, 200 ], [ 300, 300 ] ]).on find('#map')
Examples can be found in the features
and spec/dummy/spec/features
folders.
After checking out the repo, run bundle
to install dependencies. Then, you might want to run rake
to make sure the tests are green. The spec/dummy
folder contains a dummy Rails application, which is tested by the specs in spec/dummy/spec/
folder (mostly by RSpec and Cucumber features using capybara
and selenium-webdriver
).
- Fork it ( https://github.com/[my-github-username]/leaflet-draw-rails/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request