Hi all, I am facing issue with the lat and lng of google map.

the issue in my list.erb I have _list_map.erb(partial)
in my list.erb I am using below code

<script>

function initialize() {
   var mapOptions = {
     zoom: 14,
     center: new google.maps.LatLng(24.7282, 46.7485)
   };

   var map = new google.maps.Map(document.getElementById('map-canvas'),
       mapOptions);

   var marker = new google.maps.Marker({
     position: map.getCenter(),
     map: map,
     title: 'Click to zoom'
   });

   google.maps.event.addListener(map, 'center_changed', function() {
     // 3 seconds after the center of the map has changed, pan back to the
     // marker.
     window.setTimeout(function() {
       map.panTo(marker.getPosition());
     }, 3000);
   });

   google.maps.event.addListener(marker, 'click', function() {
     map.setZoom(8);
     map.setCenter(marker.getPosition());
   });
}

//google.maps.event.addDomListener(window, 'load', initialize);

</script>

and in my partial

<script>
     jQuery(function(cash) {
         // Asynchronously Load the map API
         var script = document.createElement('script');
         script.src =
"https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initialize";
         document.body.appendChild(script);
     });

function initialize() {
     alert('<%=@transport_details.lat %>','<%= @transport_details.lng %>');
   var mapOptions = {
     zoom: 14,
     center: new google.maps.LatLng('<%=@lat %>','<%= @lng %>')
   };

   var map = new google.maps.Map(document.getElementById('map-canvas'),
       mapOptions);

   var marker = new google.maps.Marker({
     position: map.getCenter(),
     map: map,
     title: 'Click to zoom'
   });

   google.maps.event.addListener(map, 'center_changed', function() {
     // 3 seconds after the center of the map has changed, pan back to the
     // marker.
     window.setTimeout(function() {
       map.panTo(marker.getPosition());
     }, 3000);
   });

   google.maps.event.addListener(marker, 'click', function() {
     map.setZoom(8);
     map.setCenter(marker.getPosition());
   });
   google.maps.event.addDomListener(window, 'load', initialize);

}


     </script>

I am passing lat and lng from db.

but it is taking values from list.erb page only it is not taking the values
which I am passing. Where did I go wrong can anyone help me.


Thanks in Advance

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/916b1fbb-49c6-4cb1-aab4-8429a3bae606%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 22, '14 at 10:12a
activeApr 22, '14 at 10:12a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Keerthi priya: 1 post

People

Translate

site design / logo © 2022 Grokbase