我已经在谷歌地图上成功列出了我的“停车”摊位,但是,我尝试了多次尝试整合<%= link_to parking %>
,所以当点击带有daily_price的信息窗口进入停车视图时。我应该在哪里/如何放置link_to?看着一些解决方案仍在摸不着头脑。这样的新手。
谢谢
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>