gmap_coordinates_picker 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +26 -11
- data/app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb +16 -5
- data/app/views/gmap_coordinate_picker/_render_map.html.erb +13 -7
- data/lib/gmap_coordinates_picker/version.rb +1 -1
- data/lib/gmap_coordinates_picker/view_helper.rb +3 -3
- metadata +16 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0472f16439c4db09787af0bde4417558ac8745c9
|
4
|
+
data.tar.gz: c43733c68eea66557ad0d2f53c726ac0ad782172
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2fe0e6b3d32030d34d693767b1c3268de4f68d6410e38cd2b88a512c1c7f9583c1c2318e4dd89277db5957ebd0415806fbe6a63434751449b56207c3ce86c08
|
7
|
+
data.tar.gz: 58a0858461f5a37b23986e03ff467f894369aaf1212f20c6683409ba32f73733f06dff3d77c4afc5ef160df7746aedae6ee612f3d658a865b4dad2663455cf75
|
data/README.md
CHANGED
@@ -11,19 +11,19 @@ Usage
|
|
11
11
|
add the following to your `Gemfile`:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem "gmap_coordinates_picker"
|
14
|
+
gem " gmap_coordinates_picker"
|
15
15
|
```
|
16
16
|
|
17
17
|
Then, add in your form:
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
<%= form.gmap_coordinate_picker :
|
20
|
+
<%= form.gmap_coordinate_picker :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 :
|
26
|
+
<%= render_gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
27
27
|
```
|
28
28
|
To display static map:
|
29
29
|
|
@@ -44,17 +44,32 @@ beside the option depicted on the example above it can be configured with the fo
|
|
44
44
|
- 'static' - to display only static map, by default it set to false and the map will be editable
|
45
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 object
|
46
46
|
|
47
|
+
General configuration options
|
48
|
+
=============================
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
+
You can configure the following default values by overriding these values using:
|
51
|
+
GmapCoordinatesPicker.configure method.
|
52
|
+
|
53
|
+
lat_column #= :latitude
|
54
|
+
lng_column #= :longitude
|
55
|
+
default_coordinates #= [23.727666666, 90.410550] #Dhaka (my home town) center point :)
|
56
|
+
map_handler #= 'gMapObj'
|
57
|
+
zoom_level #= 10
|
58
|
+
map_container_class #= 'gmap_coordinate_picker_container'
|
59
|
+
map_width #= '600px'
|
60
|
+
map_height #= '400px'
|
61
|
+
|
62
|
+
There's a handy generator that generates the default configuration file into config/initializers directory.
|
63
|
+
Run the following generator command, then edit the generated file.
|
50
64
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
- passing option is simple and gmap_conf option depricated
|
65
|
+
```ruby
|
66
|
+
rails g gmap_coordinates_picker:config
|
67
|
+
```
|
55
68
|
|
56
|
-
|
57
|
-
|
69
|
+
VERSION
|
70
|
+
=======
|
71
|
+
-0.1.0
|
72
|
+
- Rails4 support
|
58
73
|
-0.0.3
|
59
74
|
- `static map` feature added
|
60
75
|
- `javascript map handler` support added
|
@@ -1,14 +1,23 @@
|
|
1
|
-
<%= javascript_include_tag ("
|
1
|
+
<%= javascript_include_tag ("https://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
|
2
2
|
<script type="text/javascript">
|
3
3
|
var <%= map_handler%> = <%= map_handler%> || {};
|
4
|
+
var <%= map_handler%>Marker = <%= map_handler%>Marker || {};
|
4
5
|
|
5
6
|
jQuery(function () {
|
6
7
|
var marker = null;
|
7
|
-
var
|
8
|
+
var defaultPoint = null;
|
9
|
+
var center = null;
|
10
|
+
|
11
|
+
<% if lat_column_value && lng_column_value%>
|
12
|
+
defaultPoint = new google.maps.LatLng(<%= lat_column_value%>, <%=lng_column_value %>);
|
13
|
+
<% end %>
|
14
|
+
<% unless default_coordinates.empty?%>
|
15
|
+
center = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);
|
16
|
+
<% end %>
|
8
17
|
|
9
18
|
var myOptions = {
|
10
19
|
zoom: <%=zoom_level %>,
|
11
|
-
center:
|
20
|
+
center: center,
|
12
21
|
mapTypeId:google.maps.MapTypeId.ROADMAP
|
13
22
|
};
|
14
23
|
|
@@ -17,11 +26,13 @@
|
|
17
26
|
|
18
27
|
<% if lat_column_value && lng_column_value%>
|
19
28
|
marker = new google.maps.Marker({
|
20
|
-
position:
|
29
|
+
position:defaultPoint,
|
21
30
|
map:map
|
22
31
|
});
|
23
32
|
<% end%>
|
24
33
|
|
34
|
+
<%= map_handler%>Marker = marker;
|
35
|
+
|
25
36
|
google.maps.event.addListener(map, 'click', function(e) {
|
26
37
|
updateLocation(e.latLng);
|
27
38
|
});
|
@@ -35,7 +46,7 @@
|
|
35
46
|
map: map
|
36
47
|
});
|
37
48
|
}
|
38
|
-
|
49
|
+
<%= map_handler%>Marker = marker;
|
39
50
|
map.setCenter(location);
|
40
51
|
jQuery("#<%= lat_dom_id%>").val(location.lat());
|
41
52
|
jQuery("#<%=lng_dom_id %>").val(location.lng());
|
@@ -1,26 +1,32 @@
|
|
1
|
-
<%= javascript_include_tag ("
|
1
|
+
<%= javascript_include_tag ("https://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
|
2
2
|
<script type="text/javascript">
|
3
3
|
var <%= map_handler%> = <%= map_handler%> || {};
|
4
4
|
|
5
5
|
jQuery(function () {
|
6
6
|
var marker = null;
|
7
|
-
var
|
7
|
+
var defaultPoint = null
|
8
8
|
|
9
|
+
try {
|
10
|
+
defaultPoint = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);
|
11
|
+
}
|
12
|
+
catch (err) {
|
13
|
+
|
14
|
+
}
|
9
15
|
var myOptions = {
|
10
16
|
zoom: <%=zoom_level %>,
|
11
|
-
center:
|
12
|
-
mapTypeId:google.maps.MapTypeId.ROADMAP
|
17
|
+
center: defaultPoint,
|
18
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP
|
13
19
|
};
|
14
20
|
|
15
21
|
var map = new google.maps.Map(document.getElementById("<%=map_container%>"), myOptions);
|
16
22
|
<%= map_handler%> = map;
|
17
23
|
|
18
24
|
marker = new google.maps.Marker({
|
19
|
-
position:
|
20
|
-
map:map
|
25
|
+
position: defaultPoint,
|
26
|
+
map: map
|
21
27
|
});
|
22
28
|
|
23
29
|
});
|
24
30
|
</script>
|
25
|
-
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
|
31
|
+
<div class="<%= map_container_class %>" id="<%= map_container %>" style="<%= "width:#{map_width};height:#{map_height}" %>">
|
26
32
|
</div>
|
@@ -10,8 +10,8 @@ module GmapCoordinatesPicker #:nodoc
|
|
10
10
|
lat_column = options[:lat_column] || options[:gmap_conf][:lat_column] || GmapCoordinatesPicker.config.lat_column
|
11
11
|
lng_column = options[:lng_column] || options[:gmap_conf][:lng_column] || GmapCoordinatesPicker.config.lng_column
|
12
12
|
default_coordinates = options[:default_coordinates] || GmapCoordinatesPicker.config.default_coordinates
|
13
|
-
lat_column_value = options[:object].present? ? options[:object].send(lat_column) : default_coordinates[0]
|
14
|
-
lng_column_value = options[:object].present? ? options[:object].send(lng_column) : default_coordinates[1]
|
13
|
+
lat_column_value = options[:object].present? ? options[:object].send(lat_column) || default_coordinates[0] : default_coordinates[0]
|
14
|
+
lng_column_value = options[:object].present? ? options[:object].send(lng_column) || default_coordinates[1] : default_coordinates[1]
|
15
15
|
prefix = options[:object].present? ? options[:object].class.name.downcase : "gmap_coordinate_picker"
|
16
16
|
lat_dom_id = "#{prefix}_#{lat_column}"
|
17
17
|
lng_dom_id = "#{prefix}_#{lng_column}"
|
@@ -25,7 +25,7 @@ module GmapCoordinatesPicker #:nodoc
|
|
25
25
|
:map_container_class => options[:map_container_class] || GmapCoordinatesPicker.config.map_container_class,
|
26
26
|
:map_width => options[:map_width] || GmapCoordinatesPicker.config.map_width,
|
27
27
|
:map_height => options[:map_height] || GmapCoordinatesPicker.config.map_height,
|
28
|
-
:default_coordinates => options[:default_coordinates]
|
28
|
+
:default_coordinates => options[:default_coordinates].empty? ? GmapCoordinatesPicker.config.default_coordinates : options[:default_coordinates],
|
29
29
|
}
|
30
30
|
|
31
31
|
editable_map_locals = {
|
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmap_coordinates_picker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Muntasim Ahmed
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 3.1.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 3.1.0
|
30
27
|
description: It works without any dependency to any third party library
|
31
28
|
email:
|
32
29
|
- ahmed2tul@gmail.com
|
@@ -34,43 +31,42 @@ executables: []
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
37
|
- app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb
|
38
38
|
- app/views/gmap_coordinate_picker/_render_map.html.erb
|
39
39
|
- lib/generators/gmap_coordinates_picker/config_generator.rb
|
40
40
|
- lib/generators/gmap_coordinates_picker/templates/gmap_coordinates_picker_config.rb
|
41
|
+
- lib/gmap_coordinates_picker.rb
|
41
42
|
- lib/gmap_coordinates_picker/config.rb
|
42
43
|
- lib/gmap_coordinates_picker/engine.rb
|
43
44
|
- lib/gmap_coordinates_picker/form_builder.rb
|
44
45
|
- lib/gmap_coordinates_picker/formtastic.rb
|
45
46
|
- lib/gmap_coordinates_picker/version.rb
|
46
47
|
- lib/gmap_coordinates_picker/view_helper.rb
|
47
|
-
- lib/gmap_coordinates_picker.rb
|
48
|
-
- MIT-LICENSE
|
49
|
-
- Rakefile
|
50
|
-
- README.md
|
51
48
|
homepage: ''
|
52
49
|
licenses: []
|
50
|
+
metadata: {}
|
53
51
|
post_install_message:
|
54
52
|
rdoc_options: []
|
55
53
|
require_paths:
|
56
54
|
- lib
|
57
55
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
56
|
requirements:
|
60
|
-
- -
|
57
|
+
- - ">="
|
61
58
|
- !ruby/object:Gem::Version
|
62
59
|
version: '0'
|
63
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
61
|
requirements:
|
66
|
-
- -
|
62
|
+
- - ">="
|
67
63
|
- !ruby/object:Gem::Version
|
68
64
|
version: '0'
|
69
65
|
requirements: []
|
70
66
|
rubyforge_project:
|
71
|
-
rubygems_version:
|
67
|
+
rubygems_version: 2.2.2
|
72
68
|
signing_key:
|
73
|
-
specification_version:
|
69
|
+
specification_version: 4
|
74
70
|
summary: works to provide an easy to use Google Maps interface for displaying and
|
75
71
|
setting geographic co-ordinates
|
76
72
|
test_files: []
|