0.0
No commit activity in last 3 years
No release in over 3 years
Add a coordinate field with a google map handler to place markers auto updating the fields
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

<= 5.2.1, >= 4.1
<= 1.4.2, >= 0.6
 Project Readme

Rails Admin Map field

A simple gem to work with rails_admin that allow coordinate field update via a google map.

Usage

gem "rails_admin_map"

Run this

rails generate rails_admin_map:install

Then add an attr_accessor :coordinates to your active record model

class MyAwesomeModel < ActiveRecord::Base
  attr_accessor :coordinates
end

Then, add in your rails admin model initializer
config/initializers/rails_admin/modelName.rb

RailsAdmin.config do |config|
  config.model MyAwesomeModel do
    edit do
      field :coordinates, :map
    end
  end
end

After, add you google map api key(s) to the config/application.rb

# Map api key
config.map_api_key = 'YOUR_KEY_HERE'

# Map geocoding key (optional)
config.geo_api_key = 'YOUR_KEY_HERE'

Config

  • latitude_field - the name of the latitude field that forms the the co-ordinate with the latitude field specified. Defaults to "latitude"
  • longitude_field - the name of the longitude field that forms the the co-ordinate with the latitude field specified. Defaults to "longitude"
  • default_zoom - Map default zoom.
  • default_latitude - Default latitude when latitude fields is empty
  • default_longitude - Default latitude when longitude fields is empty A more complicated configuration example:
RailsAdmin.config do |config|
  config.model MyAwesomeModel do
    edit do
      field :coordinates, :map do
        latitude_field :latitude
        longitude_field :longitude
        default_latitude 40.712784
        default_longitude -74.005941
        default_zoom 10
      end
    end
  end
end