Php data and tags google maps

Asked

Viewed 284 times

0

I own a foreach taking some data from the bank, among them 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> ";
}

Satida:

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 the following, taking this address data, I would like to launch these addresses as bookmarks in google maps to facilitate visualization, 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 do I get the data I receive on getEndereco and inside the addMarker ?

2 answers

1


I ended up getting it this way. I don’t 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>

-1

Just add inside the Foreach function.

foreach ($screenplay->List screenplay($romanticism) the $data) {

echo $dados->getRomaneio() . " - ";

echo $dados->getPlaca() . " - ";

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

echo ($script->Formatadata($data->getDtSaidaRomance())) . " - ";

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

addMarker('Address here');

}

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

Function addMarker(address){ HERE ADDS THE FUNCTION OF ADDING THE MARKER! NEW MARKER };

Browser other questions tagged

You are not signed in. Login or sign up in order to post.