Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 1.57 KB

README.md

File metadata and controls

64 lines (41 loc) · 1.57 KB

Leaflet::Measure

This is a gem to add the measure plugin for leaflet to a rails project.

It does not have any additions, just makes the code available to the assets pipeline.

Installation

Add this line to your application's Gemfile:

gem 'leaflet-measure'

And then execute:

$ bundle

Or install it yourself as:

$ gem install leaflet-measure

Usage

This is what i did in my code:

map.html.haml

#big_map
=javascript_tag do
  =raw "var lat =#{@type_logger.default_lat};"
  =raw "var lng =#{@type_logger.default_lng};"
  =raw "var zoom = 7;"
  = render :partial => 'maps/loggers_farms.js'

application.css

#big_map { height: 800px; }

/app/views/maps/_logger_farms.js

  var map = L.map('big_map').setView([lat, lng], zoom);

  L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade',
        maxZoom: 18
  }).addTo(map);
  var measureControl = L.control.measure({localization:'nl', primaryLengthUnit:'meters', secondaryLengthUnit:'kilometers', primaryAreaUnit: "hectares"});
  measureControl.addTo(map);

Contributing

I don't know if i have much time to follow up !

Bug reports and pull requests are welcome on GitHub at https://github.com/bodata/leaflet-measure.

License

The gem is available as open source under the terms of the MIT License.