rails_admin_google_map 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c619860f0f650a331c96e796180d01d9dc7b132
4
- data.tar.gz: c925f44aeb56dbd27b92aabaa24a54a6447d28c5
3
+ metadata.gz: 18829f87ba89158bd1c92f6d3f1dbd2a6066a64d
4
+ data.tar.gz: bda787f4380558dc256d0ff9dc762a804e46919d
5
5
  SHA512:
6
- metadata.gz: 4e2ca3c9f608b1cedf0827614da54457359087525bd1f15e65647e40b8d72a40938d86ec80f63855fc3139a43bd9ad949e5ba53e9a15be865c06ec36bf759565
7
- data.tar.gz: 0f16794a66326bcac6577b3b1a8b5dc25f33c829f99efcc4c6fb1b61bbd232a095c724782ae12d19d43d9df090883475ab25413958dcba87313f3c4085eb3fc2
6
+ metadata.gz: a2cbc2be167946f64a5dd5190e98e4eac0157c38a50b6d2779fbd444d6ba0a3f397e8f1ffe36871d8cb656a70662b39503ace2d13bb37d525c501a936bac54b1
7
+ data.tar.gz: 34b65960e59f803dc9dff4974f3aba26efadebf4d36c47f37e87340f3e28e1fb07e2acc39a20336d4c2f8226acc20c44499287bf8d72521af98a0003985875f9
@@ -1,13 +1,17 @@
1
1
  <%= form.send :text_field, nil, name:'_search', id: field.dom_name + '_search', class: 'form-control', style: 'width: 100%; border-radius: 0;', value: '' %>
2
- <script async defer
3
- src="https://maps.googleapis.com/maps/api/js?key=<%= field.google_api_key %>&libraries=places&callback=initMap">
4
- </script>
5
2
  <div class="ra-google-map-container" id="<%= field.dom_name %>" style="width:100%; min-height:350px"></div>
6
3
  <%= form.send :hidden_field, field.method_name, id: form.options[:as].to_s + '_' + field.name.to_s, value: field.form_value %>
7
4
 
8
5
  <script type="text/javascript">
6
+ if(!(typeof google === 'object' && typeof google.maps === 'object')) {
7
+ var url = 'https://maps.googleapis.com/maps/api/js?key=<%= field.google_api_key %>&language=<%= field.locale %>&libraries=places&callback=initMap';
8
+ $.getScript(url);
9
+ } else {
10
+ initMap();
11
+ }
9
12
  var map = {};
10
13
  var markers;
14
+
11
15
  function initMap() {
12
16
  markers = [];
13
17
  var myOptions = {
@@ -0,0 +1,29 @@
1
+ <%- field = local_assigns[:field] %>
2
+ <div class="ra-google-map-container" id="google_maps_container" style="width:100%; min-height:350px"></div>
3
+
4
+ <script type="text/javascript">
5
+ if(!(typeof google === 'object' && typeof google.maps === 'object')) {
6
+ var url = 'https://maps.googleapis.com/maps/api/js?key=<%= field.google_api_key %>&language=<%= field.locale %>&libraries=places&callback=initMap';
7
+ $.getScript(url);
8
+ } else {
9
+ initMap();
10
+ }
11
+
12
+ var map = {};
13
+ var markers;
14
+
15
+ function initMap() {
16
+ var myOptions = {
17
+ zoom: 15,
18
+ center: new google.maps.LatLng(<%= field.value['location']['latitude'] %>, <%= field.value['location']['longitude'] %>),
19
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
20
+ scrollwheel: false
21
+ };
22
+ map = new google.maps.Map(document.getElementById("google_maps_container"), myOptions);
23
+
24
+ new google.maps.Marker({
25
+ position: new google.maps.LatLng(<%= field.value['location']['latitude'] %>, <%= field.value['location']['longitude'] %>),
26
+ map: map
27
+ });
28
+ }
29
+ </script>
@@ -43,7 +43,22 @@ module RailsAdmin
43
43
  end
44
44
 
45
45
  register_instance_option :formatted_value do
46
- value.present? ? JSON.pretty_generate(value) : nil
46
+ if bindings[:controller].action_name == 'show'
47
+ render do
48
+ bindings[:view].render(partial: "rails_admin/main/google_map",
49
+ locals: { field: self })
50
+ end.call
51
+ else
52
+ value.present? ? JSON.pretty_generate(value) : nil
53
+ end
54
+ end
55
+
56
+ register_instance_option(:libs) do
57
+ %w( places ).join(',')
58
+ end
59
+
60
+ register_instance_option(:locale) do
61
+ 'en'
47
62
  end
48
63
 
49
64
  def dom_name
@@ -1,3 +1,3 @@
1
1
  module RailsAdminGoogleMap
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_google_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOVACS Nicolas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -41,6 +41,7 @@ files:
41
41
  - README.md
42
42
  - Rakefile
43
43
  - app/views/rails_admin/main/_form_google_map.html.erb
44
+ - app/views/rails_admin/main/_google_map.html.erb
44
45
  - lib/rails_admin_google_map.rb
45
46
  - lib/rails_admin_google_map/engine.rb
46
47
  - lib/rails_admin_google_map/version.rb
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  version: '0'
65
66
  requirements: []
66
67
  rubyforge_project:
67
- rubygems_version: 2.5.2
68
+ rubygems_version: 2.6.8
68
69
  signing_key:
69
70
  specification_version: 4
70
71
  summary: Easy implentation of google map adress field in rails_admin