Coder Social home page Coder Social logo

jeff235255 / gmap_coordinates_picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amuntasim/gmap_coordinates_picker

0.0 2.0 0.0 31 KB

allows convenient way to update lat lng values for gmap enabled entities

License: MIT License

Ruby 72.96% HTML 27.04%

gmap_coordinates_picker's Introduction

Gmap Cordinates Picker

works to provide an easy to use Google Maps interface for displaying and setting geographic co-ordinates .

Where a latitude and longitude is set on the model, it is indicated by a marker shown on a Google map centered at the marker. The administrator can change the value of these fields by clicking on the desired new location on the map.

Demo app source code

https://github.com/amuntasim/gmap-coordicate-picker-demo

Usage

add the following to your Gemfile:

gem " gmap_coordinates_picker"

Then, add in your form:

<%= form.gmap_coordinate_picker api_key: GOOGLE_MAP_API_KEY, :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng], autocomplete: { enable: true, class: 'form-control' }  %>

Or, user is as form helper:

<%= render_gmap_coordinate_picker api_key: GOOGLE_MAP_API_KEY, :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng], autocomplete: { enable: true, class: 'form-control' }  %>

To display static map:

<%= render_gmap_coordinate_picker api_key: GOOGLE_MAP_API_KEY,  :static => 'true', :zoom_level => 10 , :default_coordinates => [lat,lng]  %>

Configuration

beside the option depicted on the example above it can be configured with the following:

  • map_container_class - custom class for the map container
  • map_width - default "600px
  • map_height - default "400px"
  • api_key - Google Map api key
  • 'static' - to display only static map, by default it set to false and the map will be editable
  • 'map_handler' - javascript map object to operate custom event on rendered map by default gMapObj is assigned as map object. You can implement any google map API methods like setCenter, zoom with that object
  • 'autocomplete' - enable autocomplete with input class - default "{ enable: true, class: 'form-control' }"

General configuration options

You can configure the following default values by overriding these values using: GmapCoordinatesPicker.configure method.

lat_column #= :latitude lng_column #= :longitude default_coordinates #= [23.727666666, 90.410550] #Dhaka (my home town) center point :) map_handler #= 'gMapObj' zoom_level #= 10 map_container_class #= 'gmap_coordinate_picker_container' map_width #= '600px' map_height #= '400px' autocomplete #= { enable: true, class: 'form-control' }

There's a handy generator that generates the default configuration file into config/initializers directory. Run the following generator command, then edit the generated file.

rails g gmap_coordinates_picker:config

VERSION

-0.1.0 - Rails4 support

-0.0.3 - static map feature added - javascript map handler support added

-0.0.2 render_gmap_coordinate_picker for for helper

LICENSE

is licensed under the MIT license.

Copyright (C) 2013 by Muntasim Ahmed

Inspired from rails_admin_map_field (https://github.com/trademobile/rails_admin_map_field)

gmap_coordinates_picker's People

Contributors

amuntasim avatar jackyvo avatar ashrafuzzaman avatar jeff235255 avatar abo-elleef 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.