Commit a6d1568718c69ab239005df04cb4d3a9c66fc9a1

Authored by Rafael Martins
1 parent bbb8594c

Update lat and lng at profile

app/views/maps/_google_map.js.erb
@@ -25,6 +25,8 @@ function codeAddress() { @@ -25,6 +25,8 @@ function codeAddress() {
25 if (status == google.maps.GeocoderStatus.OK) { 25 if (status == google.maps.GeocoderStatus.OK) {
26 map.setCenter(results[0].geometry.location); 26 map.setCenter(results[0].geometry.location);
27 marker.setPosition(results[0].geometry.location); 27 marker.setPosition(results[0].geometry.location);
  28 + getAddress(marker.getPosition());
  29 +
28 $('profile_data_lat').value = results[0].geometry.location.lat(); 30 $('profile_data_lat').value = results[0].geometry.location.lat();
29 $('profile_data_lng').value = results[0].geometry.location.lng(); 31 $('profile_data_lng').value = results[0].geometry.location.lng();
30 $('location-fields').removeClassName("loading"); 32 $('location-fields').removeClassName("loading");
@@ -93,6 +95,10 @@ function updateFields(place) { @@ -93,6 +95,10 @@ function updateFields(place) {
93 $('profile_data_lng').value = position.lng(); 95 $('profile_data_lng').value = position.lng();
94 $('location-fields').removeClassName("loading"); 96 $('location-fields').removeClassName("loading");
95 97
  98 + form = jQuery('#location-form')[0];
  99 + form.lat = marker.getPosition().lat();
  100 + form.lng = marker.getPosition().lng();
  101 +
96 var components_len = place.address_components.size(); 102 var components_len = place.address_components.size();
97 103
98 if(components_len < 2) 104 if(components_len < 2)
app/views/maps/edit_location.rhtml
@@ -2,7 +2,8 @@ @@ -2,7 +2,8 @@
2 <div class="error"> 2 <div class="error">
3 <%= flash[:error] %> 3 <%= flash[:error] %>
4 </div> 4 </div>
5 -<% form_for :profile_data, :url => {:action => 'edit_location'} do |f| %> 5 +
  6 +<% form_for :profile_data, :url => {:action => 'edit_location'}, :html => {:id => 'location-form'} do |f| %>
6 7
7 <div id='location-fields'> 8 <div id='location-fields'>
8 <%= select_country _('Country'), 'profile_data', 'country', {:class => 'type-select'} %> 9 <%= select_country _('Country'), 'profile_data', 'country', {:class => 'type-select'} %>
@@ -23,8 +24,8 @@ @@ -23,8 +24,8 @@
23 <p><div id="location-map"></div></p> 24 <p><div id="location-map"></div></p>
24 </div> 25 </div>
25 26
26 - <%= f.hidden_field(:lat) %>  
27 - <%= f.hidden_field(:lng) %> 27 + <%= f.hidden_field :lat %>
  28 + <%= f.hidden_field :lng %>
28 29
29 <% end %> 30 <% end %>
30 31