0

I have successfully listed my "parking" stalls on a google map, however, I have tried several attempts to integrate <%= link_to parking %> so when the info window with daily_price is clicked goes to parking view. where/how should I place the link_to? Looked at a few solutions still scratching my head. such a newbie.

thanks

search.html.erb

 <!--google map-->
 <div id="map" style="width: 100%; height: 100%"></div>


     function initialize(parkings) {
         var location = {lat: 53.5444, lng: -113.4909}

         if (parkings.length > 0) {
             location = {lat: parkings[0].latitude, lng: parkings[0].longitude}
         }

         var map = new google.maps.Map(document.getElementById('map'), {
             center: location,
             zoom: 12
         });

         var marker, inforwindow;

         parkings.forEach(function(parking) {
             marker = new google.maps.Marker({
                 position: {lat: parking.latitude, lng: parking.longitude},
                 map: map
             });

             infowindow = new google.maps.InfoWindow({
                 content: "<div class='map_price'>$" + parking.daily_price + "</div>"
             });

             infowindow.open(map, marker);
         })
     }

     google.maps.event.addDomListener(window, 'load', function() {
         initialize(<%= raw @arrParkings.to_json %>)
     });
 </script>

fool-dev
  • 7,671
  • 9
  • 40
  • 54
Zurch
  • 39
  • 10
  • Question is not much clear. What is your question? Are you not finding how to use `link_to` to above code? – fool-dev Feb 15 '18 at 12:28
  • Yes how do I link this portion to my parking model each has s separate Id : content div class=map price – Zurch Feb 15 '18 at 14:04

0 Answers0