Git Product home page Git Product logo

rails_admin_google_map's Introduction

Gem Version

RailsAdminGoogleMap

Implementation of user friendly google map field in rails_admin. Any suggestions are welcome.

Example

TODO

  • Test with multiple google map field within the same model
  • More Google map options

Installation

Add this line to your application's Gemfile:

gem 'rails_admin_google_map'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_admin_google_map

Usage

Strategy: use a serialized field to store all datas returned by Google.

Migration example:

def change
  add_column :users, :google_map, :text
end

In your model:

class User < ActiveRecord::Base
  serialize :google_map, JSON
end

RailsAdmin configuration

RailsAdmin.config do |config|
  config.model User do
    edit do
      field :google_map, :google_map do
        google_api_key 'APIKEY'
        default_latitude -34.0
        default_longitude 151.0
      end
    end
  end
end

Example of JSON stored values, everything is built dynamically.

{
  "location":{
      "latitude":45.5016889,
      "longitude":-73.56725599999999
   },
   "formatted_address":"Montréal, QC, Canada",
   "locality":"Montréal",
   "political":"Canada",
   "administrative_area_level_3":"Pointe-Calumet",
   "administrative_area_level_2":"Communauté-Urbaine-de-Montréal",
   "administrative_area_level_1":"Québec",
   "country":"Canada"
}

Example of usage in a view

<%= u.google_map['location']['latitude'] %>
<%= u.google_map['country'] %>
<%= u.google_map['formatted_address'] %>

License

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

rails_admin_google_map's People

Contributors

nicovak avatar zmokizmoghi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.