The Map (google maps API - javascript) stops working when I add a function in the script!

1

The map to appear when I put the AllLink function, when I remove it the map will appear again as always

  var map;
  var markers = [];
  function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: 75.15975385, lng: -75.15975385},
      zoom: 8
    });
    LigaTudo();
  }
     var i array_nome, array_lat, array_lng ,string_arraynm, string_arraylt, string_arraylg;
string_arraynm= “<?php echo $string_arraynm; ?>“;
 string_arraylt= “<?php echo $string_arraylt; ?>“;
   string_arraylg= “<?php echo $string_arraylg ?>“;
     array_nome = string_arraynm.split(“|”);
       array_lat = string_arraylt.split(“|”);
         array_lng = string_arraylg.split(“|”);
         function LigaTudo(){
          for (var i = array_nome.length - 1; i >= 0; i--) {
            var local = new google.maps.LatLng(array_lat[i],array_lng[i]);

            var mark = new google.maps.Marker({
position: local,
title: $array_nome[i]
});

          }
         }
</script>
<script type="text/javascript" src="pontinhos.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script><scriptsrc="https://maps.googleapis.com/maps/api/js?key=minhachave&callback=initMap"
async defer></script>

The above part is where the functions are, below I leave the php (I do not know if there can be anything in it).

<?php
$pontonm = array();
$pontolt = array();
$pontolg = array();
// Aqui você se conecta ao banco
$mysqli = new mysqli('localhost', 'root', 'root', 'tcc');
// Executa uma consulta que pega cinco notícias
$sql = "SELECT 'nome_pub','lat_pub','lng_pub' FROM 'publicos'";
$query = $mysqli->query($sql);
while ($dados = $query->fetch_assoc()) {


 array_push($pontonm,$dados['nome_pub']);
 array_push($pontolt,$dados['lat_pub']);
 array_push($pontolg,$dados['lng_pub']);
   }




$string_arraynm = implode ( "|",$pontonm);
$string_arraylt = implode ( "|",$pontolt);
$string_arraylg = implode ( "|",$pontolg);
 ?>

I would like to know if someone could identify the problem, and how do I use the function (it puts the database data to create markers) without the map stop working, thanks in advance.

    
asked by anonymous 25.06.2017 / 02:58

0 answers