No release in over a year
An agile way to implement Google Maps. in a model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.8.0
~> 0.10.0
 Project Readme

Ruby On Rails Google Maps By Pete

An agile way to implement Google Maps geolocation in a Ruby On Rails scaffold

Support

Ruby On Rails: 5, 6, 7

Installation

Add this line to your application's Gemfile:

gem 'google_maps_by_pete'

Go to your application's directory in Terminal and run the command:

bundle install

Usage

Let's create a example for a Place scaffold:

  1. Let's create a new rails app:
rails new myapp
  1. Create the database:
bundle exec rake db:create
  1. Go to your application's directory in Terminal and run the command:
bundle exec rails g scaffold Place name:string description:text
  1. Add this line to your application's Gemfile:
gem 'google_maps_by_pete'
  1. Go to your application's directory in Terminal and run:
bundle install
  1. Go to the application directory in Terminal and run the following command to install the necessary code and files from the gem:
bundle exec rake 'install_google_maps_by_pete[Place]'
  1. Add jQuery to your layout file: /app/views/layouts/application.html.erb
<script src='/google_maps_by_pete/jquery-3.6.0.min.js'></script>
  1. Add maps.css to your layout file: /app/views/layouts/application.html.erb
<link rel='stylesheet' href='/google_maps_by_pete/maps.css'>
  1. Paste this partial to your _form.html.erb file: /app/views/places/_form.html.erb
<%= render 'shared/google_maps_by_pete', api_key: 'your_google_api_key',  height: '500px', center_map_on: {lat: 25.761681, lng: -80.191788}, model: place%>
  1. Allow parameters (lat and lng) in your controller: /app/controllers/places_controller.rb
def place_params
   params.require(:place).permit(:name, :description, :lat, :lng)
end

Video Tutorial

Watch this video to see how it works

IMAGE ALT TEXT HERE

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/peterconsuegra/google_maps_by_pete. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the GoogleMapsByPete project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.