Google Maps bookmark

2

I have the application below, which adds markers to the map according to the past addresses, but it seems to me that it has a maximum limit. You only get 10 points, but there are more than 10 past addresses. Could someone tell me why and how do I solve this case? I need a little higher limit. Is there any way to get this? It is like ?

Code:

<?php
include_once 'connection_open.php';
include_once 'DAO/RoteiroDAO.php';
include_once 'controller/RoteiroCont.php';
include_once 'model/Roteiro.php';

$roteiro = new RoteiroControle($conn);

$romaneio = filter_input(INPUT_POST, 'romaneio');

if ($romaneio) {
    $romaneio = $romaneio;
} else {
    $romaneio = 'null';
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Roteiros</title>
        <script src="http://code.jquery.com/jquery-1.7.1.min.js"type="text/javascript"></script>
        <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script><linkhref="css/main.css" rel="stylesheet" />
    </head>
    <body>
        <div class="container_12">
            <form action="index" method="POST">
                <fieldset>
                    <label>Romaneio:</label>
                    <input type="text" name="romaneio" value="<?php
                    if ($romaneio == 'null') {
                        echo '';
                    } else {
                        echo $romaneio;
                    }
                    ?>"/>
                    <label>Placa:</label>
                    <input type="text" name= "placa" value=""/>
                    <br>
                    <button type="submit">Filtrar</button>
                </fieldset>
            </form>

            <?php if ($romaneio != 'null') { ?>
                <table class="tableModif">
                    <thead>
                        <tr>
                            <th>Romaneio</th>
                            <th>Placa</th>
                            <th>Cte</th>
                            <th>Data Saida</th>
                            <th>Endereço</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($roteiro->ListaRoteiro($romaneio) as $dados) { ?>
                            <tr>
                                <td><?php echo $dados->getRomaneio(); ?></td>
                                <td><?php echo $dados->getPlaca(); ?></td>
                                <td><?php echo $dados->getCte(); ?></td>
                                <td><?php echo ($roteiro->FormataData($dados->getDtSaidaRomaneio())); ?></td>
                                <td><?php echo $dados->getEndereco(); ?></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            <?php } ?>

            <br>

            <div class="map" id="map" style="height: 500px; width: 100%;"></div>

            <br><br>

        </div>

        <script src="js/gmaps.js" type="text/javascript"></script>
        <script src="js/markers.js" type="text/javascript"></script>    
        <script>
            $(function () {

                //Definir o centro do mapa [endereço + elm div]
                initMap('Av. Paulista, 500, São Paulo, SP', 'map');

                <?php foreach ($roteiro->ListaRoteiro($romaneio) as $dados) { ?>

                    //Adicionar marcadores  [endereço + descricao html)
                    addMarker('<?php echo $dados->getEndereco(); ?>', '<?php echo $dados->getEndereco(); ?>');

                <?php } ?>
            })
        </script>
    </body>
</html>

The addMarker function that I call the file markers.js is this:

function addMarker(address, html){
    GMaps.geocode({
        address: address,
        callback: function (results, status) {
            if (status == 'OK') {
                var latlng = results[0].geometry.location;
                if (html == "") {
                    html = address;
                }
                lat = latlng.lat();
                lng = latlng.lng();
                var icon = "icons/m1.png";
                map.addMarker({
                    lat: lat,
                    lng: lng,
                    icon: icon,
                    //title: address,
                    infoWindow: {
                        content: html
                    }
                });
            }
        }
    })
}

Output:

Of these, it shows only the first 10 addresses on the map.

$(function () {

  initMap('Av. Paulista, 500, São Paulo, SP', 'map');

  addMarker('RUA SAO FRANCISCO DE SALLES 191 Ap 96 - CENTRO - DIADEMA - SP', '');                
  addMarker('RUA PROFESSOR EVANDRO CAIAFA ESQUIVEL 235 Apto 5 - CENTRO - DIADEMA - SP', '');              
  addMarker('TUPIRITAMA 353 - AMERICANOPOLIS - SAO PAULO - SP', '');
  addMarker('BAEPENDY 595 - CAMPANARIO - DIADEMA - SP', '');
  addMarker('AV MOINHO FABRINI 339 - INDEPENDENCIA - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('AVENIDA PIRAPORINHA 540 Bl yel - PLANALTO - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('AVENIDA WINSTON CHURCHILL 1477 Cond - RUDGE RAMOS - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('RUA SARMENTO DE BEIRES- 421  - JARDIM PORTUGAL - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('RUA PAPA PAULO VI-200  - SANTA TEREZINHA - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('RUA SERRA DO PILAR-129  - COOPERATIVA - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('AVENIDA SENADOR VERGUEIRO 1310 Apto - PINHEIROS - SAO PAULO - SP', '');
  addMarker('RUA LEILA GONCALVES-481  - ANCHIETA - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('AVENIDA GETULIO VARGAS 648 Casa c - VILA BAETA NEVES - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('RUA PAULINO DE ABREU 039 casa 3 - FERRAZOPOLIS - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('AVENIDA CAMINHO DO MAR 2427 Apt. - RUDGE RAMOS - SAO BERNARDO DO CAMPO - SP', '');
  addMarker('AV PEREIRA BARRETO 2444 - TAMBORE - BARUERI - SP', '');
  addMarker('RUA JORGE CHAMMAS-272  - VILA AMERICA - SANTO ANDRE - SP', '');
  addMarker('MELVIN JONES-74  - VILA BASTOS - SANTO ANDRE - SP', '');
  addMarker('RUA ADOLFO BASTOS 1239 sala - VILA BASTOS - SANTO ANDRE - SP', '');
});
    
asked by anonymous 25.11.2016 / 14:26

2 answers

3

It seems the Google API limits the markup when trying to do several at once.

You will have to put a delay between each call of the addMarker function, you can use your loop to do this, like this:

<?php foreach ($roteiro->ListaRoteiro($romaneio) as $i => $dados) { ?>

      setTimeout(function() {
          addMarker('<?php echo $dados->getEndereco(); ?>', '<?php echo $dados->getEndereco(); ?>');
      }, 400*parseInt("<?php echo $i; ?>"));

<?php } ?>

NOTE: If you have a lot of points, and it takes a lot of time to load, you can try to decrease the delay by changing 200 in setTimeout , but test to make sure you are loading all of them without problems.

You can also test this alternative that will put a delay of 10 on 10 function calls:

<?php foreach ($roteiro->ListaRoteiro($romaneio) as $i => $dados) { ?>

      setTimeout(function() {
          addMarker('<?php echo $dados->getEndereco(); ?>', '<?php echo $dados->getEndereco(); ?>');
      }, 400*parseInt("<?php echo floor($i/10); ?>"));

<?php } ?>
    
01.12.2016 / 17:05
0

Young, comments the callback IF and see if the result remains the same. If you display all the entries, please let us know what we're trying to solve from there.

  //    if (status == 'OK') {
            var latlng = results[0].geometry.location;
            if (html == "") {
                html = address;
            }
            lat = latlng.lat();
            lng = latlng.lng();
            var icon = "icons/m1.png";
            map.addMarker({
                lat: lat,
                lng: lng,
                icon: icon,
                //title: address,
                infoWindow: {
                    content: html
                }
            });
        //}
    
01.12.2016 / 14:42