Côté contrôleur
controller.rb
def show
    @location = Location.find(params[:id])
  end
vue côté
<script>
  {
    const num1 = <%= @location.num1 %>   <%#Substitution%>
    const num2 = <%= @location.num2 %>   <%#Substitution%>
    var MyLatLng = new google.maps.LatLng(num1, num2);
    var Options = {
      zoom: 15, //Valeur d'échelle de la carte
      center: MyLatLng, //Coordonnées du centre de la carte
      mapTypeId: 'roadmap' //Type de carte
    };
    var map = new google.maps.Map(document.getElementById('map'), Options);
  }
</script>
        Recommended Posts