gmpoint 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +47 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/locations.js.coffee +16 -12
- data/app/helpers/gmpoint/gmpoint_helper.rb +8 -11
- data/gmpoint.gemspec +3 -3
- metadata +4 -4
- data/README.rdoc +0 -42
data/README.markdown
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# GMPOIT
|
2
|
+
|
3
|
+
This is gem for help to point on google map. You can marker your address and search your location
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
### in your Gemfile
|
7
|
+
gem 'gmpoint', git: 'git@github.com:dangluan/gmpoint.git'
|
8
|
+
|
9
|
+
## Setting Up
|
10
|
+
|
11
|
+
bundle
|
12
|
+
rails g gmpoint:install
|
13
|
+
rails g gmpoint MODEL
|
14
|
+
rake db:migrate
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
### Add code below into application.html.erb :
|
19
|
+
<%= show_map_helper your_model %>
|
20
|
+
|
21
|
+
Example:
|
22
|
+
<%= show_map_helper :users %>
|
23
|
+
|
24
|
+
|
25
|
+
### You can set options for view
|
26
|
+
|
27
|
+
#### You can set "width" , "height" for map view
|
28
|
+
<%= show_map_helper :users, {width: 400, height: 200} %>
|
29
|
+
|
30
|
+
#### You can set "searchbox_with" for search box
|
31
|
+
<%= show_map_helper :users, {searchbox_width: 300} %>
|
32
|
+
|
33
|
+
#### You can show or hide your search box
|
34
|
+
<%= show_map_helper :users, {searchbox: 'show', width: 400, height: 200, searchbox_width: 300} %>
|
35
|
+
|
36
|
+
and when you want to hide the search box
|
37
|
+
<%= show_map_helper :users, {searchbox: 'none', width: 400, height: 200, searchbox_width: 300} %>
|
38
|
+
|
39
|
+
#### You can only set show or point to map using attribute "allow"
|
40
|
+
<%= show_map_helper :users, {allow: 'show', searchbox: 'none', width: 400, height: 200, searchbox_width: 300} %>
|
41
|
+
|
42
|
+
and when you want to point
|
43
|
+
<%= show_map_helper :users, {allow: 'point', searchbox: 'none', width: 400, height: 200, searchbox_width: 300} %>
|
44
|
+
|
45
|
+
Example:
|
46
|
+
<%= show_map_helper :users, {width: 400, height: 200, searchbox_width: 300} %>
|
47
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -12,18 +12,16 @@ window.initJsMap = ->
|
|
12
12
|
|
13
13
|
|
14
14
|
window.gmpoint_map = new google.maps.Map(document.getElementById("map_canvas"), opts)
|
15
|
-
window.
|
16
|
-
window.gmpoint_marker = new google.maps.Marker({position: opts.center, draggable: true})
|
15
|
+
window.gmpoint_marker = new google.maps.Marker({position: opts.center, draggable: false})
|
17
16
|
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
17
|
window.gmpoint_info_window.close()
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
window.gmpoint_marker.setMap(window.gmpoint_map)
|
19
|
+
if $("#gmpoint_map_allow").attr('value') == "point"
|
20
|
+
google.maps.event.addListener window.gmpoint_map, "click", (event) ->
|
21
|
+
latlng = event.latLng
|
22
|
+
window.geopoint_handle(latlng)
|
23
|
+
else
|
24
|
+
window.geopoint_search_map($("#gmpoint_location_address"))
|
27
25
|
|
28
26
|
window.geopoint_search_map = (dom) ->
|
29
27
|
addressField = $(dom)
|
@@ -39,12 +37,18 @@ window.geopoint_search_map = (dom) ->
|
|
39
37
|
window.geopoint_handle = (attr)->
|
40
38
|
$("#gmpoint_location_latitude").val(attr.lat())
|
41
39
|
$("#gmpoint_location_longitude").val(attr.lng())
|
40
|
+
window.gmpoint_info_window = new google.maps.InfoWindow({
|
41
|
+
size: new google.maps.Size(20, 20)
|
42
|
+
})
|
42
43
|
window.gmpoint_marker.setPosition(attr)
|
43
44
|
geocoder = new google.maps.Geocoder()
|
44
|
-
|
45
|
+
if $("#gmpoint_map_allow").attr('value') == "point"
|
46
|
+
window.gmpoint_info_window.open(window.gmpoint_map, window.gmpoint_marker)
|
47
|
+
else
|
48
|
+
|
45
49
|
window.gmpoint_info_window.setContent("Loading...")
|
46
50
|
geocoder.geocode {'latLng': attr}, (results, status) ->
|
47
51
|
if status == google.maps.GeocoderStatus.OK
|
48
52
|
if results[1]
|
49
53
|
window.gmpoint_info_window.setContent(results[0].formatted_address)
|
50
|
-
$("#gmpoint_location_address").val(results[0].formatted_address)
|
54
|
+
$("#gmpoint_location_address").val(results[0].formatted_address)
|
@@ -5,24 +5,21 @@ module Gmpoint::GmpointHelper
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def show_map_helper(model_name, opts={})
|
8
|
-
|
8
|
+
|
9
|
+
object = model_name.to_s.singularize.classify.constantize.find(params[:id])
|
10
|
+
@address = object.location_address
|
11
|
+
opts = {allow: 'show', searchbox: 'show', width: 800, height: 400, latitude: 1.3667, longitude: 103.75, zoom: 13, style: "border: 1px solid #green;", searchbox_width: 400}.merge(opts)
|
9
12
|
[
|
10
|
-
content_tag(:div, :id => "geopoint_search_box_container", style: "width: #{opts[:
|
11
|
-
tag(:input, type: :text, placeholder: 'Search', id: "gmpoint_#{model_name}_search_box", style: "width: #{opts[:
|
13
|
+
content_tag(:div, :id => "geopoint_search_box_container", style: "width: #{opts[:searchbox_width]}px; margin: 0 auto; margin-bottom: 10px; display: #{opts[:searchbox]}") do
|
14
|
+
tag(:input, type: :text, placeholder: 'Search', id: "gmpoint_#{model_name}_search_box", style: "width: #{opts[:searchbox_width]}px; border:1px solid #{:color};")
|
12
15
|
end,
|
13
16
|
content_tag(:div, '', id: "map_canvas", style: "width: #{opts[:width]}px; height: #{opts[:height]}px; #{opts[:style]}"),
|
14
17
|
content_tag(:div, '', class: "data-location", data: {model: model_name, latitude: opts[:latitude] , longitude: opts[:longitude] , zoom: opts[:zoom]}),
|
18
|
+
tag(:input, type: :hidden, value: "#{opts[:allow]}", name: "allow", id: "gmpoint_map_allow"),
|
15
19
|
tag(:input, type: :hidden, value: '', name: "#{model_name}[location_latitude]", id: "gmpoint_location_latitude"),
|
16
20
|
tag(:input, type: :hidden, value: '', name: "#{model_name}[location_longitude]", id: "gmpoint_location_longitude"),
|
17
|
-
tag(:input, type: :hidden, value:
|
21
|
+
tag(:input, type: :hidden, value: "#{@address}", name: "#{model_name}[location_address]", id: "gmpoint_location_address"),
|
18
22
|
javascript_tag("window.initJsMap();")
|
19
23
|
].join.html_safe
|
20
24
|
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
25
|
end
|
data/gmpoint.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gmpoint"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Peter Dang"]
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.email = "peter@rubify.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
-
"README.
|
17
|
+
"README.markdown"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".DS_Store",
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"Gemfile",
|
23
23
|
"Gemfile.lock",
|
24
24
|
"LICENSE.txt",
|
25
|
-
"README.
|
25
|
+
"README.markdown",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"app/assets/.DS_Store",
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -113,14 +113,14 @@ executables: []
|
|
113
113
|
extensions: []
|
114
114
|
extra_rdoc_files:
|
115
115
|
- LICENSE.txt
|
116
|
-
- README.
|
116
|
+
- README.markdown
|
117
117
|
files:
|
118
118
|
- .DS_Store
|
119
119
|
- .document
|
120
120
|
- Gemfile
|
121
121
|
- Gemfile.lock
|
122
122
|
- LICENSE.txt
|
123
|
-
- README.
|
123
|
+
- README.markdown
|
124
124
|
- Rakefile
|
125
125
|
- VERSION
|
126
126
|
- app/assets/.DS_Store
|
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
segments:
|
152
152
|
- 0
|
153
|
-
hash: -
|
153
|
+
hash: -1008877307821399153
|
154
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
156
|
requirements:
|
data/README.rdoc
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
= gmpoint
|
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} %>
|
26
|
-
Description goes here.
|
27
|
-
|
28
|
-
== Contributing to gmpoint
|
29
|
-
|
30
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
31
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
32
|
-
* Fork the project.
|
33
|
-
* Start a feature/bugfix branch.
|
34
|
-
* Commit and push until you are happy with your contribution.
|
35
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
36
|
-
* 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.
|
37
|
-
|
38
|
-
== Copyright
|
39
|
-
|
40
|
-
Copyright (c) 2012 Peter Dang. See LICENSE.txt for
|
41
|
-
further details.
|
42
|
-
|