gmap_coordinates_picker 0.0.2 → 0.0.3
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/{README.rdoc → README.md} +17 -2
- data/Rakefile +0 -18
- data/app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb +2 -2
- data/app/views/gmap_coordinate_picker/_render_map.html.erb +26 -0
- data/lib/gmap_coordinates_picker/version.rb +1 -1
- data/lib/gmap_coordinates_picker/view_helper.rb +31 -21
- metadata +4 -3
data/{README.rdoc → README.md}
RENAMED
@@ -17,13 +17,18 @@ gem " gmap_coordinates_picker"
|
|
17
17
|
Then, add in your form:
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
<%= form.gmap_coordinate_picker :gmap_conf => {:lat_column => 'latitude', :lng_column => 'longitude', :zoom_level => 10
|
20
|
+
<%= form.gmap_coordinate_picker :gmap_conf => {:lat_column => 'latitude', :lng_column => 'longitude' }, :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
21
21
|
```
|
22
22
|
|
23
23
|
Or, user is as form helper:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
<%= render_gmap_coordinate_picker :gmap_conf => {:lat_column => 'latitude', :lng_column => 'longitude', :zoom_level => 10
|
26
|
+
<%= render_gmap_coordinate_picker :gmap_conf => {:lat_column => 'latitude', :lng_column => 'longitude' }, :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
27
|
+
```
|
28
|
+
To display static map:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
<%= render_gmap_coordinate_picker :static => 'true', :zoom_level => 10 , :default_coordinates => [lat,lng] %>
|
27
32
|
```
|
28
33
|
|
29
34
|
|
@@ -36,9 +41,19 @@ beside the option depicted on the example above it can be configured with the fo
|
|
36
41
|
- `map_width` - default "600px
|
37
42
|
- `map_height` - default "400px"
|
38
43
|
- `api_key` - Google Map api key (optional)
|
44
|
+
- 'static' - to display only static map, by default it set to false and the map will be editable
|
45
|
+
- '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 onject
|
39
46
|
|
40
47
|
|
48
|
+
VERSION
|
49
|
+
=======
|
50
|
+
|
51
|
+
-0.0.3
|
52
|
+
- `static map` feature added
|
53
|
+
- `javascript map handler` support added
|
41
54
|
|
55
|
+
-0.0.2
|
56
|
+
render_gmap_coordinate_picker for for helper
|
42
57
|
|
43
58
|
LICENSE
|
44
59
|
=======
|
data/Rakefile
CHANGED
@@ -4,24 +4,6 @@ begin
|
|
4
4
|
rescue LoadError
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
require 'rdoc/rdoc'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
RDoc::Task = Rake::RDocTask
|
13
|
-
end
|
14
|
-
|
15
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
-
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = 'GmapCoordinatesPicker'
|
18
|
-
rdoc.options << '--line-numbers'
|
19
|
-
rdoc.rdoc_files.include('README.rdoc')
|
20
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
7
|
|
26
8
|
Bundler::GemHelper.install_tasks
|
27
9
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= javascript_include_tag ("http://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
|
2
2
|
<script type="text/javascript">
|
3
|
-
var
|
3
|
+
var <%= map_handler%> = <%= map_handler%> || {};
|
4
4
|
|
5
5
|
jQuery(function () {
|
6
6
|
var marker = null;
|
@@ -13,7 +13,7 @@
|
|
13
13
|
};
|
14
14
|
|
15
15
|
var map = new google.maps.Map(document.getElementById("<%=map_container%>"), myOptions);
|
16
|
-
|
16
|
+
<%= map_handler%> = map;
|
17
17
|
|
18
18
|
<% if lat_column_value && lng_column_value%>
|
19
19
|
marker = new google.maps.Marker({
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= javascript_include_tag ("http://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
|
2
|
+
<script type="text/javascript">
|
3
|
+
var <%= map_handler%> = <%= map_handler%> || {};
|
4
|
+
|
5
|
+
jQuery(function () {
|
6
|
+
var marker = null;
|
7
|
+
var latlng = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);
|
8
|
+
|
9
|
+
var myOptions = {
|
10
|
+
zoom: <%=zoom_level %>,
|
11
|
+
center:latlng,
|
12
|
+
mapTypeId:google.maps.MapTypeId.ROADMAP
|
13
|
+
};
|
14
|
+
|
15
|
+
var map = new google.maps.Map(document.getElementById("<%=map_container%>"), myOptions);
|
16
|
+
<%= map_handler%> = map;
|
17
|
+
|
18
|
+
marker = new google.maps.Marker({
|
19
|
+
position:new google.maps.LatLng(<%= default_coordinates[0]%>,<%=default_coordinates[1] %>),
|
20
|
+
map:map
|
21
|
+
});
|
22
|
+
|
23
|
+
});
|
24
|
+
</script>
|
25
|
+
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
|
26
|
+
</div>
|
@@ -1,35 +1,45 @@
|
|
1
1
|
module GmapCoordinatesPicker #:nodoc
|
2
2
|
module ViewHelper #:nodoc
|
3
3
|
def render_gmap_coordinate_picker(options={})
|
4
|
-
lat_column = options[:gmap_conf][:lat_column]
|
5
|
-
lng_column = options[:gmap_conf][:lng_column]
|
6
|
-
default_coordinates = options[:default_coordinates] || [0, 0]
|
7
|
-
lat_column_value = options[:object].present? ? options[:object].send(lat_column) : default_coordinates[0]
|
8
|
-
lng_column_value = options[:object].present? ? options[:object].send(lng_column) : default_coordinates[1]
|
9
|
-
prefix = options[:object].present? ? options[:object].class.name.downcase : "gmap_coordinate_picker"
|
10
|
-
lat_dom_id = "#{prefix}_#{lat_column}"
|
11
|
-
lng_dom_id = "#{prefix}_#{lng_column}"
|
12
4
|
|
13
|
-
|
5
|
+
unless options[:static].to_s == 'true'
|
6
|
+
lat_column = options[:gmap_conf][:lat_column]
|
7
|
+
lng_column = options[:gmap_conf][:lng_column]
|
8
|
+
lat_column_value = options[:object].present? ? options[:object].send(lat_column) : default_coordinates[0]
|
9
|
+
lng_column_value = options[:object].present? ? options[:object].send(lng_column) : default_coordinates[1]
|
10
|
+
prefix = options[:object].present? ? options[:object].class.name.downcase : "gmap_coordinate_picker"
|
11
|
+
lat_dom_id = "#{prefix}_#{lat_column}"
|
12
|
+
lng_dom_id = "#{prefix}_#{lng_column}"
|
13
|
+
end
|
14
|
+
|
15
|
+
default_locals = {
|
14
16
|
:api_key => options[:api_key],
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:lng_column_value => lng_column_value,
|
19
|
-
:zoom_level => options[:gmap_conf][:zoom_level] || 10,
|
20
|
-
:map_container => "#{prefix}_#{lat_column}_#{lng_column}_container",
|
17
|
+
:map_handler => options[:map_handler] || 'gMapObj',
|
18
|
+
:zoom_level => options[:zoom_level] || 10,
|
19
|
+
:map_container => "gmap_coordinate_picker_container_#{Time.now.to_i}",
|
21
20
|
:map_container_class => options[:map_container_class],
|
22
21
|
:map_width => options[:map_width] || "600px",
|
23
22
|
:map_height => options[:map_height] ||"400px",
|
24
|
-
:default_coordinates => default_coordinates,
|
25
|
-
:lat_dom_id => lat_dom_id,
|
26
|
-
:lng_dom_id => lng_dom_id,
|
27
|
-
:lat_field => lat_lng_field(lat_column, lat_column_value,lat_dom_id, options),
|
28
|
-
:lng_field => lat_lng_field(lng_column, lng_column_value,lng_dom_id, options)
|
23
|
+
:default_coordinates => options[:default_coordinates] || [0, 0],
|
29
24
|
}
|
30
25
|
|
26
|
+
editable_map_locals = {
|
31
27
|
|
32
|
-
|
28
|
+
:lat_column => lat_column,
|
29
|
+
:lng_column => lng_column,
|
30
|
+
:lat_column_value => lat_column_value,
|
31
|
+
:lng_column_value => lng_column_value,
|
32
|
+
:map_container => "#{prefix}_#{lat_column}_#{lng_column}_container#{Time.now.to_i}",
|
33
|
+
:lat_dom_id => lat_dom_id,
|
34
|
+
:lng_dom_id => lng_dom_id,
|
35
|
+
:lat_field => lat_lng_field(lat_column, lat_column_value, lat_dom_id, options),
|
36
|
+
:lng_field => lat_lng_field(lng_column, lng_column_value, lng_dom_id, options)
|
37
|
+
}
|
38
|
+
unless options[:static].to_s == 'true'
|
39
|
+
render :partial => 'gmap_coordinate_picker/gmap_coordinate_picker', :locals => default_locals.merge(editable_map_locals)
|
40
|
+
else
|
41
|
+
render :partial => 'gmap_coordinate_picker/render_map', :locals => default_locals
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmap_coordinates_picker
|
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:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -35,6 +35,7 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb
|
38
|
+
- app/views/gmap_coordinate_picker/_render_map.html.erb
|
38
39
|
- lib/gmap_coordinates_picker/engine.rb
|
39
40
|
- lib/gmap_coordinates_picker/form_builder.rb
|
40
41
|
- lib/gmap_coordinates_picker/version.rb
|
@@ -42,7 +43,7 @@ files:
|
|
42
43
|
- lib/gmap_coordinates_picker.rb
|
43
44
|
- MIT-LICENSE
|
44
45
|
- Rakefile
|
45
|
-
- README.
|
46
|
+
- README.md
|
46
47
|
homepage: ''
|
47
48
|
licenses: []
|
48
49
|
post_install_message:
|