No commit activity in last 3 years
No release in over 3 years
A gem to easily pick co-ordinates from google map and map them to input fields (latitude and longitude)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.8
~> 10.0
 Project Readme

GmapPointPicker¶ ↑

This light-weigh gem allows you to bind input fields to google map’s click action. The fields get populated with the latitude and longitude of the location clicked on the map.

Installation¶ ↑

Add this line to your application’s Gemfile:

+gem ‘gmap_point_picker’+

And then execute:

+$ bundle install+

Or install it yourself as:

$ gem install gmap_point_picker

Usage¶ ↑

GmapPointPicker.configure¶ ↑

You may use the block style configuration. The following code could be placed into a config/initializers/gmap_point_picker.rb when used in a Rails project.

GmapPointPicker.configure do |config|
  config.api_key      = 'xxxxxxxyyyyzzzzzzzzz' #Required if config.load_js = true
  config.load_js      = boolean                #default false
  config.latitude     = "48.32324234"
  config.longitude    = "-78.23232343"         #These are required for initial map center
  config.map_div_id   = "map-canvas"           #div id which will be used to load the map. default 'map-canvas'
  config.lat_field_id = "latitude"             #input field id where latitude will be populated on click. default 'latitude'
  config.lng_field_id = "longitude"            #input field id where longitude will be populated on click. default 'longitude'
end

These configurations can be overridden when calling gmap_point_picker_bind OR gmap_point_picker_bind_no_jquery

Example¶ ↑

<%= gmap_point_picker_bind :key => "your_api_key_here",
      :latitude        => 34.2323232,    #Center
      :longitude       => -78.423232,
      :map_div_id      => 'map-canvas',  #Div for map
      :load_js         => true,          #Should we load the google maps api for you?
      :search_field_id => 'gmap-search', #Text box for searching on map
      :lat_field_id    => 'latitude',    #Fields that will be populated on map click
      :lng_field_id    => 'longitude'
%>

<div>
  <input type="text" id="latitude" /><br />
  <input type="text" id="longitude" /><br />
  <input type="text" id="gmap-search" />
</div>
<div id="map-canvas" style="height:600px;"></div>

If you do not have jQuery loaded, you can use the alternative gmap_point_picker_bind_no_jquery with the same options. WARNING: gmap_point_picker_bind_no_jquery will not work with IE8

Development¶ ↑

After checking out the repo, run ‘bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run ‘bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](rubygems.org).

Contributing¶ ↑

  1. Fork it ( github.com/laiqjafri/gmap_point_picker/fork )

  2. Create your feature branch (‘git checkout -b my-new-feature`)

  3. Commit your changes (‘git commit -am ’Add some feature’‘)

  4. Push to the branch (‘git push origin my-new-feature`)

  5. Create a new Pull Request