{"id":13463391,"url":"https://github.com/axyjo/leaflet-rails","last_synced_at":"2025-03-25T06:31:58.422Z","repository":{"id":2627489,"uuid":"3613616","full_name":"axyjo/leaflet-rails","owner":"axyjo","description":"This gem provides the leaflet.js map display library for your Rails 5 application.","archived":true,"fork":false,"pushed_at":"2024-07-15T01:34:25.000Z","size":21179,"stargazers_count":178,"open_issues_count":0,"forks_count":71,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-01T23:38:32.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/leaflet-rails","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axyjo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-03-03T20:49:08.000Z","updated_at":"2024-10-01T02:56:06.000Z","dependencies_parsed_at":"2024-01-13T17:55:32.051Z","dependency_job_id":"3e6fdee2-e8fa-43fe-825d-b2aeddbc8f53","html_url":"https://github.com/axyjo/leaflet-rails","commit_stats":{"total_commits":1077,"total_committers":69,"mean_commits":"15.608695652173912","dds":0.2534818941504178,"last_synced_commit":"270a27e4854ff9821f5e15fe980f6f247cd1678b"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axyjo%2Fleaflet-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axyjo%2Fleaflet-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axyjo%2Fleaflet-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axyjo%2Fleaflet-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axyjo","download_url":"https://codeload.github.com/axyjo/leaflet-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222045607,"owners_count":16921981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:52.611Z","updated_at":"2024-10-29T12:31:17.678Z","avatar_url":"https://github.com/axyjo.png","language":"Ruby","readme":"[![Build Status](https://travis-ci.org/axyjo/leaflet-rails.png?branch=master)](https://travis-ci.org/axyjo/leaflet-rails)\n[![Gem Version](https://badge.fury.io/rb/leaflet-rails.png)](http://badge.fury.io/rb/leaflet-rails)\n\nNote: Intent to Deprecate\n================\nAs of 2024-07-14, Rails 5 is long past its EOL. Rails 6+ support alternative Javascript bundling solutions, which work a lot better than this approach does. As such, I intend on marking this project as deprecated on or after 2024-10-01. Any Leaflet upgrades prior to that date will still be honoured.\n\n\nQuickstart Guide\n================\n\nTo start using the leaflet-rails gem, follow the steps below (assuming you use the default asset pipeline):\n\nFirst, add the following code to your `Gemfile`.\n\n```ruby\ngem 'leaflet-rails'\n```\n\nThen, 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:\n\n```\n= require leaflet\n```\n\nAfter 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:\n\n```\n= require leaflet\n```\n\nAt this point, you may skip the first two steps of the [Leaflet Quick Start guide](http://leafletjs.com/examples/quick-start/) and start at the third step (adding the map `div` to a view).\n\n\nVersion Parity\n==============\n\n`leaflet-rails` keeps version parity with the upstream `leaflet.js` library. Before v0.7.7 the versions were not always in sync, as noted in the table below.\n\n| leaflet-rails  | leaflet.js | Reason |\n| ------------- | ------------- | ------|\n| 0.7.4  | 0.7.3  | Requested in #33 because of large gap between master and rubygems.org.|\n| 0.7.5  | 0.7.5  | leaflet.js 0.7.4 was reverted. |\n| 0.7.6  | ----   | Skipped to sync with upstream. |\n| 0.7.7  | 0.7.7  | Sync version numbers with upstream. |\n| 1.9.5  | 1.9.4  | Adding intent to deprecate post-install message. |\n\nHelpers\n=======\n\nTo 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`:\n\n```ruby\nLeaflet.tile_layer = \"http://{s}.tile.cloudmade.com/YOUR-CLOUDMADE-API-KEY/997/256/{z}/{x}/{y}.png\"\n# 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\nLeaflet.attribution = \"Your attribution statement\"\nLeaflet.max_zoom = 18\n```\n\nIf you are using a tile layer which requires non-default subdomains such as [MapQuest-OSM Tiles](http://developer.mapquest.com/web/products/open/map), you can set the subdomains like this:\n\n```ruby\nLeaflet.tile_layer = \"http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png\"\nLeaflet.subdomains = ['otile1', 'otile2', 'otile3', 'otile4']\n```\n\nYou will then be able to call the ```#map``` helper method in a view, and make sure that the helper method is inside an erb tag like so:\n```ruby\n\u003c%= map(:center =\u003e {\n  :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n  :zoom =\u003e 18\n}) %\u003e\n```\n\nYou can also add any number of markers like so:\n```ruby\nmap(:center =\u003e {\n    :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n    :zoom =\u003e 18\n  },\n  :markers =\u003e [\n    {\n       :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n    }\n  ]\n)\n```\n\nAdding a `:popup` element to a marker hash will also generate a popup for a maker:\n\n```ruby\nmap(:center =\u003e {\n    :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n    :zoom =\u003e 18\n  },\n  :markers =\u003e [\n     {\n       :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n       :popup =\u003e \"Hello!\"\n     }\n  ]\n)\n```\n\nIf you want to override the map settings you have set in the initializer, you can also add them to the helper method:\n\n```ruby\nmap(:center =\u003e {\n    :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n    :zoom =\u003e 18\n  },\n  :tile_layer =\u003e \"http://{s}.somedomain.com/somepath/{z}/{x}/{y}.png\",\n  :attribution =\u003e \"Some other attribution text\",\n  :max_zoom =\u003e 4\n)\n```\n\nIf you want to have multiple maps on same page , you should add unique container_id in helper method for each map:\n\n```ruby\nmap(:container_id =\u003e \"first_map\", :center =\u003e {\n    :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n    :zoom =\u003e 18\n})\n\nmap(:container_id =\u003e \"second_map\", :center =\u003e {\n    :latlng =\u003e [51.52238797921441, -0.08366235665359283],\n    :zoom =\u003e 18\n})\n```\n\n","funding_links":[],"categories":["Time \u0026 Space","Installation","Ruby"],"sub_categories":["Geocoding \u0026 Maps"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxyjo%2Fleaflet-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxyjo%2Fleaflet-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxyjo%2Fleaflet-rails/lists"}