No commit activity in last 3 years
No release in over 3 years
Simple implementation of Yandex maps in rails admin.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

< 6, > 4.2
 Project Readme

Gem Version

RailsAdminYamapField

Simple implementation of Yandex maps in rails admin.

Inspired by these projects:

Installation

Add this line to your application's Gemfile:

gem 'rails_admin_yamap_field'

And then execute:

$ bundle

Usage

Add attr_accessor ya_map to you model for which you need to show the map or define ya_map and ya_map= methods as you wish, for example:

class Address < ApplicationRecord
  # others methods
  def ya_map=(lat_lon)
    self[:lat], self[:lon] = lat_lon.split(",")
  end
  def ya_map
    [lat, lon].join(",")
  end
  # others methods
end

Available options for configure in rails_admin:

  • center_lat - map center latitude
  • center_long - map center longitude
  • zoom_level - map zoom level
  • map_html_width - width div map container: default '100%'
  • map_html_height - height div map container: default '500px'
  • map_lang - language map: default 'ru_RU', for other values see this ref
  • api_key - api key for enterprise version: default 'nil'
  • latitude_field - latitude attribute name in you model: default 'latitude'
  • longitude_field - longitude attribute name in you model: default 'longitude'

Example:

class Address < ApplicationRecord
  attr_accessor :ya_map

  rails_admin do
    field :lat, :hidden
    field :lon, :hidden
    field :ya_map, :yamap_field do
      map_html_width "600px"
      latitude_field :lat
      longitude_field :lon
     end
  end
end

Screenshot

Sample screenshot

References

Contributing

Feel free to send pull requests or write issue.

License

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