Permalink
Browse files

it works

  • Loading branch information...
1 parent 3079e48 commit 17119b1486a911a59800ddaac13150ce4d0eafb0 @kristianmandrup committed Sep 6, 2012
View
@@ -28,7 +28,7 @@ pkg
#
# For MacOS:
#
-#.DS_Store
+.DS_Store
# For TextMate
#*.tmproj
View
@@ -0,0 +1,72 @@
+# Gmaps autocomplete for Rails
+
+Extracted from [gmaps-autocomplete](https://github.com/rjshade/gmaps-autocomplete) and improved markedly and then packaged for use with Rails as an asset gem :)
+
+See it in action here: [rjshade.github.com/gmaps-autocomplete/](http://rjshade.github.com/gmaps-autocomplete/)
+
+Some more explanation here: [rjshade.com/2012/03/30/Google-Maps-autocomplete-with-jQuery-UI](/[http://www.rjshade.com/2012/03/30/Google-Maps-autocomplete-with-jQuery-UI/)
+
+## Use with Rails form helpers
+
+```ruby
+= simple_form_for(@post) do |f|
+ = f.input :address, :input_html =>{:id => 'gmaps-input-address'}, :placeholder => 'Start typing a place name...'
+```
+
+Packed and ready for the Asset pipeline :)
+
+```
+//= require gmaps-autocomplete
+```
+
+## Usage
+
+```javascript
+$(document).ready(function() {
+ GmapsAutoComplete.gmaps_init();
+ GmapsAutoComplete.autocomplete_init();
+});
+```
+
+## Configuration options
+
+`gmaps_init()` take an option hash, using the following defaults:
+
+```javascript
+ defaultOptions = {
+ mapElem: "#gmaps-canvas",
+ zoomLevel: 2,
+ mapType: google.maps.MapTypeId.ROADMAP,
+ pos: [51.751724, -1.255284],
+ inputField: '#gmaps-input-address',
+ errorField: '#gmaps-error',
+ positionOutputter: this.defaultPositionOutputter
+ };
+```
+
+`autocomplete_init` also takes an option hash, but currently only [region](https://developers.google.com/maps/documentation/geocoding/#RegionCodes) is used.
+
+```javascript
+autocomplete_init({region: 'ES'});
+```
+
+## TODO
+
+* better Javascript encapsulation
+* translation to Coffeescript and use Coffee classes :)
+
+## Contributing to gmaps-autocomplete-rails
+
+* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
+* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
+* Fork the project.
+* Start a feature/bugfix branch.
+* Commit and push until you are happy with your contribution.
+* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+== Copyright
+
+Copyright (c) 2012 Kristian Mandrup. See LICENSE.txt for
+further details.
+
View
@@ -1,19 +0,0 @@
-= gmaps-autocomplete-rails
-
-Description goes here.
-
-== Contributing to gmaps-autocomplete-rails
-
-* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
-* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
-* Fork the project.
-* Start a feature/bugfix branch.
-* Commit and push until you are happy with your contribution.
-* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
-* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
-
-== Copyright
-
-Copyright (c) 2012 Kristian Mandrup. See LICENSE.txt for
-further details.
-
View
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
gem.name = "gmaps-autocomplete-rails"
gem.homepage = "http://github.com/kristianmandrup/gmaps-autocomplete-rails"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.summary = %Q{Google Maps v3 search with jQuery UI Autocomplete, ready for use with Rails asset pipeline}
+ gem.description = %Q{Easily add autocomplete geo-functionality to your Rails app :)}
gem.email = "kmandrup@gmail.com"
gem.authors = ["Kristian Mandrup"]
# dependencies defined in Gemfile
@@ -0,0 +1,6 @@
+module GmapsAutoComplete
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
@@ -0,0 +1 @@
+# TODO - suggestions welcome ;)
@@ -1,7 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-
-describe "GmapsAutocompleteRails" do
- it "fails" do
- fail "hey buddy, you should probably rename this file and start specing for real"
- end
-end
View
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<head>
+ <meta charset='utf-8'>
+ <title>rjshade/gmaps-autocomplete @ GitHub</title>
+ <title>Google Maps and jqueryUI</title>
+ <link type="text/css" href="main.css" rel="stylesheet" />
+ <link type="text/css" href="jquery-ui/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
+
+ <!-- google maps -->
+ <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+
+ <!-- jquery -->
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+
+ <!-- jquery UI -->
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
+
+ <!-- our javascript -->
+ <script type="text/javascript" src="../vendor/assets/javascripts/gmaps-autocomplete.js"></script>
+
+ <!-- configuration -->
+ <script type="text/javascript" src="init.js"></script>
+</head>
+
+<body>
+ <a href="https://github.com/rjshade/gmaps-autocomplete"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
+
+ <div id='container'>
+ <div class="download">
+ <a href="https://github.com/rjshade/gmaps-autocomplete/zipball/master">
+ <img border="0" width="90" src="https://github.com/images/modules/download/zip.png"></a>
+ <a href="https://github.com/rjshade/gmaps-autocomplete/tarball/master">
+ <img border="0" width="90" src="https://github.com/images/modules/download/tar.png"></a>
+ </div>
+
+ <div id='instructions'>
+ <h1>Geocoding with Google Maps and jQuery UI</h1>
+ <p>This page shows how you can use the <a href="http://jqueryui.com/demos/autocomplete/">autocomplete widget</a> from <a href="http://jqueryui.com/">jQuery UI</a> in conjunction with the <a href="https://developers.google.com/maps/documentation/javascript/reference">Google Maps geocoding API</a> .
+ </p>
+ <p>
+ Start typing a in the search box to trigger the drop-down autocomplete menu. Reverse lookup is also implemented: click the map (or drag an existing marker) and the search box will be populated with the closest address Google can find.
+ </p>
+ <p>
+ The source code is on GitHub: <a href="https://github.com/rjshade/gmaps-autocomplete">rjshade/gmaps-autocomplete</a>
+ </p>
+ </div>
+
+ <hr/>
+
+ <div id='input'>
+ <input id='gmaps-input-address' placeholder='Start typing a place name...' type='text' />
+ <br/>
+ <br/>
+ Latitude: <span id='gmaps-output-latitude'></span>
+ <br/>
+ Longitude: <span id='gmaps-output-longitude'></span>
+ <br/>
+
+ <div id='gmaps-error'></div>
+ </div>
+
+ <div id='gmaps-canvas'></div>
+ </div>
+</body>
View
@@ -0,0 +1,4 @@
+$(document).ready(function() {
+ GmapsAutoComplete.gmaps_init();
+ GmapsAutoComplete.autocomplete_init();
+});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 17119b1

Please sign in to comment.