Problem with Json to load data in gmaps api

1
I'm using Rails in a college project and added the Gmaps API to my project, in it I want to display multiple points on the map by taking the coordinates of a < in JSON to create the cluster .

But the function I did not work in any way, the map appears however with no point placed in it, I'm also using the jQuery library. My JSON file is located inside my folder Javascripts in Rails , below is my code:

<div id="map"></div>
    <script type= "text/javascript">
        //Opções de iniciação do mapa

        function initMap() {
            var cin = {lat: -8.055590, lng: -34.951344}
            var map = new google.maps.Map(document.getElementById('map'), {
            zoom: 10,
            center: cin
        });


        //Função de carregar pontos do Json e jogar no mapa

        function carregarPontos() {
          $.getJSON('javascripts/pontos.json', function(pontos) {
             for (var i = 0; i < pontos.points.length; i++){
             var latLng = new google.maps.LatLng(pontos.points[i][0], pontos.points[i][1]);
             var marker = new google.maps.Marker({
             position: latLng,
             map: map
               });
            }

          });
        }

        //Infoboxes 

        var contentString = '<h1 id="pintest">Teste</h1>';
        var infowindow = new google.maps.InfoWindow({
            content: contentString
        });
            marker.addListener('click', function() {
                 infowindow.open(map, marker);
         });

        }
        //Iniciando função de carregar pontos

        carregarPontos();

My Points.json file is in this format:

I'mnotsureifit'sintherightformat,butItesteditwithanotherJSONfilethatisinthisformat:

And also does not rotate, my map appears but with no point in it.

    
asked by anonymous 05.11.2017 / 20:37

0 answers