php data and markers google maps

0

I have foreach taking some data from the bank, including the address.

foreach ($roteiro->ListaRoteiro($romaneio) as $dados) {
   echo $dados->getRomaneio() . " - ";
   echo $dados->getPlaca() . " - ";
   echo $dados->getCte() . " - ";
   echo ($roteiro->FormataData($dados->getDtSaidaRomaneio())) . " - ";
   echo $dados->getEndereco() . " <br> ";
}

Saida:

15317 - ITU-9637 - 12-5162 - 21/11/2016 - RUA ALVORADA-29, - VILA RUTE - GUARULHOS - SP, 7054080 
15317 - ITU-9637 - 12-5251 - 21/11/2016 - RUA CABO ANTÔNIO PEREIRA DA SILVA-307, - JARDIM TRANQUILIDADE - GUARULHOS - SP, 7051011 

My idea is as follows, taking these address data, I would like to post these addresses as bookmarks in google maps for easier viewing, each address a bookmark.

I'm using a JS class.

<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 
        initMap('Endereço aqui');

        //Adicionar marcadores
        addMarker('Endereço aqui');
        addMarker('Endereço aqui');

    })
</script>

My question is: How can I get the data I get in getEndereco and inside addMarker ?

    
asked by anonymous 24.11.2016 / 11:31

2 answers

1

I ended up getting this way. I do not know if it's the best but it's functional.

<script>
   $(function () {

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

      <?php foreach ($roteiro->ListaRoteiro($romaneio) as $dados) { ?>
          addMarker('<?php echo $dados->getEndereco(); ?>');
      <?php } ?>
   })
</script>
    
24.11.2016 / 16:52
-1

Just add the function inside Foreach.

  

foreach ($ roteiro-> gstartname ($ romaneio) as $ data) {

     

echo $ data-> getRomane (). "-";

     

echo $ data-> getPlate (). "-";

     

echo $ data-> getCte (). "-";

     

echo ($ script-> FormData ($ data-> getDtSaidaRomaneio ())). "-";

     

echo $ data-> getEndereco (). "
";

     
    

addMarker ('Address here');

  
     

}

If you use a non-native google maps function, you must create a function for the add marker.

  

function addMarker (address) {     HERE ADD THE FUNCTION OF ADDING THE MARKER! NEW MARKER   };

    
01.02.2017 / 08:58