gmpoint 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.DS_Store +0 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/README.rdoc +23 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/assets/.DS_Store +0 -0
- data/app/assets/javascripts/locations.js.coffee +50 -0
- data/app/assets/stylesheets/locations.css +15 -0
- data/app/helpers/gmpoint/gmpoint_helper.rb +28 -0
- data/gmpoint.gemspec +74 -0
- data/lib/generators/active_record/gmpoint_generator.rb +14 -0
- data/lib/generators/active_record/templates/migration.rb +7 -0
- data/lib/generators/gmpoint/gmpoint_generator.rb +14 -0
- data/lib/generators/gmpoint/install_generator.rb +22 -0
- data/lib/gmpoint.rb +1 -10
- metadata +47 -2
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,6 +6,7 @@ GEM
|
|
6
6
|
multi_json (~> 1.0)
|
7
7
|
bourne (1.1.2)
|
8
8
|
mocha (= 0.10.5)
|
9
|
+
geocoder (1.1.6)
|
9
10
|
git (1.2.5)
|
10
11
|
i18n (0.6.1)
|
11
12
|
jeweler (1.8.4)
|
@@ -18,6 +19,7 @@ GEM
|
|
18
19
|
mocha (0.10.5)
|
19
20
|
metaclass (~> 0.0.1)
|
20
21
|
multi_json (1.5.0)
|
22
|
+
new_responds_to_parent (0.1.5)
|
21
23
|
rake (10.0.3)
|
22
24
|
rdoc (3.12)
|
23
25
|
json (~> 1.4)
|
@@ -34,6 +36,8 @@ PLATFORMS
|
|
34
36
|
|
35
37
|
DEPENDENCIES
|
36
38
|
bundler (~> 1.2.1)
|
39
|
+
geocoder
|
37
40
|
jeweler (~> 1.8.4)
|
41
|
+
new_responds_to_parent
|
38
42
|
rdoc (~> 3.12)
|
39
43
|
shoulda
|
data/README.rdoc
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
= gmpoint
|
2
2
|
|
3
|
+
* gem 'gmpoint'
|
4
|
+
* bundle install
|
5
|
+
* rails g gmpoint:install
|
6
|
+
* rails g gmpoint User
|
7
|
+
* add attr_accessible :location_latitude, :location_longitude, :location_address inside your model
|
8
|
+
|
9
|
+
= Usage
|
10
|
+
* Add code below into application.html.erb
|
11
|
+
<%= google_map_api_js(your google api key code) %>
|
12
|
+
EX:
|
13
|
+
<%= google_map_api_js("AIzaSyA344yCug0-GhjW3XJyZmkLWLN_qtA_ziM") %>
|
14
|
+
* Add code below into anywhere you want
|
15
|
+
<%= show_map_helper your_model %>
|
16
|
+
|
17
|
+
EX:
|
18
|
+
<%= show_map_helper :users %>
|
19
|
+
|
20
|
+
You can set options for view
|
21
|
+
width , height for map view
|
22
|
+
search_box_with for search box
|
23
|
+
|
24
|
+
EX:
|
25
|
+
<%= show_map_helper :users, {width: 400, height: 200, search_box_width: 300} %>
|
3
26
|
Description goes here.
|
4
27
|
|
5
28
|
== Contributing to gmpoint
|
data/Rakefile
CHANGED
@@ -24,7 +24,7 @@ Jeweler::Tasks.new do |gem|
|
|
24
24
|
gem.version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
25
25
|
# dependencies defined in Gemfile
|
26
26
|
end
|
27
|
-
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
28
|
|
29
29
|
require 'rake/testtask'
|
30
30
|
Rake::TestTask.new(:test) do |test|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
0.0.2
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
# All this logic will automatically be available in application.js.
|
3
|
+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
4
|
+
window.initJsMap = ->
|
5
|
+
$("#geopoint_search_box_container input").keypress (e) ->
|
6
|
+
if e.keyCode == 13 # enter
|
7
|
+
window.geopoint_search_map($(@))
|
8
|
+
opts =
|
9
|
+
center: new google.maps.LatLng($('.data-location').data('latitude'), $('.data-location').data('longitude'))
|
10
|
+
zoom: $('.data-location').data('zoom')
|
11
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP
|
12
|
+
|
13
|
+
|
14
|
+
window.gmpoint_map = new google.maps.Map(document.getElementById("map_canvas"), opts)
|
15
|
+
window.gmpoint_map.setOptions({draggableCursor: 'url(http://maps.gstatic.com/mapfiles/crosshair.cur), default'})
|
16
|
+
window.gmpoint_marker = new google.maps.Marker({position: opts.center, draggable: true})
|
17
|
+
window.gmpoint_map.setCenter(window.gmpoint_marker.getPosition(), 16)
|
18
|
+
window.gmpoint_info_window = new google.maps.InfoWindow({
|
19
|
+
size: new google.maps.Size(20, 20)
|
20
|
+
})
|
21
|
+
window.gmpoint_info_window.close()
|
22
|
+
|
23
|
+
window.gmpoint_marker.setMap(window.gmpoint_map)
|
24
|
+
google.maps.event.addListener window.gmpoint_map, "click", (event) ->
|
25
|
+
latlng = event.latLng
|
26
|
+
window.geopoint_handle(latlng)
|
27
|
+
|
28
|
+
window.geopoint_search_map = (dom) ->
|
29
|
+
addressField = $(dom)
|
30
|
+
geocoder = new google.maps.Geocoder()
|
31
|
+
geocoder.geocode {address: addressField.val()}, (results, status) ->
|
32
|
+
if status == google.maps.GeocoderStatus.OK
|
33
|
+
loc = results[0].geometry.location
|
34
|
+
window.gmpoint_marker.setPosition(loc)
|
35
|
+
window.gmpoint_map.setCenter(window.gmpoint_marker.getPosition())
|
36
|
+
point = loc
|
37
|
+
window.geopoint_handle(point)
|
38
|
+
|
39
|
+
window.geopoint_handle = (attr)->
|
40
|
+
$("#gmpoint_location_latitude").val(attr.lat())
|
41
|
+
$("#gmpoint_location_longitude").val(attr.lng())
|
42
|
+
window.gmpoint_marker.setPosition(attr)
|
43
|
+
geocoder = new google.maps.Geocoder()
|
44
|
+
window.gmpoint_info_window.open(window.gmpoint_map, window.gmpoint_marker)
|
45
|
+
window.gmpoint_info_window.setContent("Loading...")
|
46
|
+
geocoder.geocode {'latLng': attr}, (results, status) ->
|
47
|
+
if status == google.maps.GeocoderStatus.OK
|
48
|
+
if results[1]
|
49
|
+
window.gmpoint_info_window.setContent(results[0].formatted_address)
|
50
|
+
$("#gmpoint_location_address").val(results[0].formatted_address)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// Place all the styles related to the locations controller here.
|
2
|
+
// They will automatically be included in application.css.
|
3
|
+
// You can use Sass (SCSS) here: http://sass-lang.com/
|
4
|
+
html { height: 100% }
|
5
|
+
body { height: 100%; margin: 0; padding: 0 }
|
6
|
+
#map_canvas {
|
7
|
+
width: 1200px;
|
8
|
+
height: 500px;
|
9
|
+
margin: 0 auto;
|
10
|
+
border:1px solid green;
|
11
|
+
}
|
12
|
+
|
13
|
+
#data-location {
|
14
|
+
display:none;
|
15
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gmpoint::GmpointHelper
|
2
|
+
|
3
|
+
def google_map_api_js(key="AIzaSyA344yCug0-GhjW3XJyZmkLWLN_qtA_ziM")
|
4
|
+
javascript_include_tag "https://maps.googleapis.com/maps/api/js?key=#{key}&sensor=true"
|
5
|
+
end
|
6
|
+
|
7
|
+
def show_map_helper(model_name, opts={})
|
8
|
+
opts = {width: 800, height: 400, latitude: 1.3667, longitude: 103.75, zoom: 13, style: "border: 1px solid #green;"}.merge(opts)
|
9
|
+
[
|
10
|
+
content_tag(:div, :id => "geopoint_search_box_container", style: "width: #{opts[:width]}px; margin: 0 auto; margin-bottom: 10px;") do
|
11
|
+
tag(:input, type: :text, placeholder: 'Search', id: "gmpoint_#{model_name}_search_box", style: "width: #{opts[:search_box_width]}px; border:1px solid #{:color};")
|
12
|
+
end,
|
13
|
+
content_tag(:div, '', id: "map_canvas", style: "width: #{opts[:width]}px; height: #{opts[:height]}px; #{opts[:style]}"),
|
14
|
+
content_tag(:div, '', class: "data-location", data: {model: model_name, latitude: opts[:latitude] , longitude: opts[:longitude] , zoom: opts[:zoom]}),
|
15
|
+
tag(:input, type: :hidden, value: '', name: "#{model_name}[location_latitude]", id: "gmpoint_location_latitude"),
|
16
|
+
tag(:input, type: :hidden, value: '', name: "#{model_name}[location_longitude]", id: "gmpoint_location_longitude"),
|
17
|
+
tag(:input, type: :hidden, value: '', name: "#{model_name}[location_address]", id: "gmpoint_location_address"),
|
18
|
+
javascript_tag("window.initJsMap();")
|
19
|
+
].join.html_safe
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_address
|
23
|
+
content_tag(:div, id: "form-add-point") do
|
24
|
+
content_tag(:p, "Address: #{@address.to_s}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/gmpoint.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "gmpoint"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Peter Dang"]
|
12
|
+
s.date = "2013-01-08"
|
13
|
+
s.description = "Help to point on Goolge Map Description"
|
14
|
+
s.email = "peter@rubify.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".DS_Store",
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"app/assets/.DS_Store",
|
29
|
+
"app/assets/javascripts/locations.js.coffee",
|
30
|
+
"app/assets/stylesheets/locations.css",
|
31
|
+
"app/helpers/gmpoint/gmpoint_helper.rb",
|
32
|
+
"gmpoint.gemspec",
|
33
|
+
"lib/generators/active_record/gmpoint_generator.rb",
|
34
|
+
"lib/generators/active_record/templates/migration.rb",
|
35
|
+
"lib/generators/gmpoint/gmpoint_generator.rb",
|
36
|
+
"lib/generators/gmpoint/install_generator.rb",
|
37
|
+
"lib/gmpoint.rb",
|
38
|
+
"test/helper.rb",
|
39
|
+
"test/test_gmpoint.rb"
|
40
|
+
]
|
41
|
+
s.homepage = "http://github.com/dangluan/gmpoint"
|
42
|
+
s.licenses = ["MIT"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = "1.8.24"
|
45
|
+
s.summary = "Help to point on Google Map"
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<geocoder>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<new_responds_to_parent>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.2.1"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<geocoder>, [">= 0"])
|
59
|
+
s.add_dependency(%q<new_responds_to_parent>, [">= 0"])
|
60
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.1"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
64
|
+
end
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<geocoder>, [">= 0"])
|
67
|
+
s.add_dependency(%q<new_responds_to_parent>, [">= 0"])
|
68
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.1"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Generators
|
5
|
+
class GmpointGenerator < ActiveRecord::Generators::Base
|
6
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
|
9
|
+
def copy_gmpoint_migration
|
10
|
+
migration_template "migration.rb", "db/migrate/gmpoint_add_columns_to_#{table_name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class GmpointAddColumnsTo<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :<%= table_name %>, :location_latitude, :float
|
4
|
+
add_column :<%= table_name %>, :location_longitude, :float
|
5
|
+
add_column :<%= table_name %>, :location_address, :string
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Gmpoint
|
2
|
+
module Generators
|
3
|
+
class GmpointGenerator < Rails::Generators::NamedBase
|
4
|
+
include Rails::Generators::ResourceHelpers
|
5
|
+
|
6
|
+
namespace "gmpoint"
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
|
9
|
+
desc "Generates Gmpoint attributes for a model given its NAME."
|
10
|
+
|
11
|
+
hook_for :orm
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'rails/generators/migration'
|
4
|
+
|
5
|
+
module Gmpoint
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
|
10
|
+
source_root File.expand_path("../../templates", __FILE__)
|
11
|
+
desc "Creates a Config file and copy locate files to your application."
|
12
|
+
class_option :orm
|
13
|
+
|
14
|
+
def copy_jsfile
|
15
|
+
["locations.js.coffee"].each do |file|
|
16
|
+
copy_file "../../../app/assets/javascripts/#{file}", "app/assets/javascripts/#{file}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/gmpoint.rb
CHANGED
@@ -1,13 +1,4 @@
|
|
1
1
|
module Gmpoint
|
2
|
-
class Engine < Rails::Engine
|
3
|
-
|
4
|
-
ActiveRecord::Base.extend(Gmpoint::ClassMethods)
|
5
|
-
|
6
|
-
ActiveRecord::Base.class_eval do
|
7
|
-
include ActionView::Helpers::JavaScriptHelper
|
8
|
-
end
|
9
|
-
|
10
|
-
ActionController::Base.extend(Gmpoint::ControllerMethods)
|
11
|
-
|
2
|
+
class Engine < Rails::Engine
|
12
3
|
end
|
13
4
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: geocoder
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: new_responds_to_parent
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
- !ruby/object:Gem::Dependency
|
15
47
|
name: shoulda
|
16
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,6 +115,7 @@ extra_rdoc_files:
|
|
83
115
|
- LICENSE.txt
|
84
116
|
- README.rdoc
|
85
117
|
files:
|
118
|
+
- .DS_Store
|
86
119
|
- .document
|
87
120
|
- Gemfile
|
88
121
|
- Gemfile.lock
|
@@ -90,6 +123,15 @@ files:
|
|
90
123
|
- README.rdoc
|
91
124
|
- Rakefile
|
92
125
|
- VERSION
|
126
|
+
- app/assets/.DS_Store
|
127
|
+
- app/assets/javascripts/locations.js.coffee
|
128
|
+
- app/assets/stylesheets/locations.css
|
129
|
+
- app/helpers/gmpoint/gmpoint_helper.rb
|
130
|
+
- gmpoint.gemspec
|
131
|
+
- lib/generators/active_record/gmpoint_generator.rb
|
132
|
+
- lib/generators/active_record/templates/migration.rb
|
133
|
+
- lib/generators/gmpoint/gmpoint_generator.rb
|
134
|
+
- lib/generators/gmpoint/install_generator.rb
|
93
135
|
- lib/gmpoint.rb
|
94
136
|
- test/helper.rb
|
95
137
|
- test/test_gmpoint.rb
|
@@ -106,6 +148,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
148
|
- - ! '>='
|
107
149
|
- !ruby/object:Gem::Version
|
108
150
|
version: '0'
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: -4153438249491434857
|
109
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
155
|
none: false
|
111
156
|
requirements:
|