2
I have the application below, which adds markers on the map according to the past addresses, but it seems to me that you have a maximum limit. It only scores 10 points, but there are more than 10 addresses passed. Would anyone know why and how I solve this case ? I need a slightly higher limit. Is there a way to get it ? And how ?
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>
<link href="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 function addMarker that I call the archive markers.js
that’s the one:
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
}
});
}
}
})
}
Exit:
Of these below shows on the map only the first 10 addresses.
$(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', '');
});
It is the limit of the Google Maps API itself.
– Mayron Ceccon
There’s an answer on that link, that the guy put 250 tags http://stackoverflow.com/questions/3059044/google-maps-js-api-v3-simple-multiple-marker-example - there’s no way to adapt my code to that ?
– KevinF
I use google maps api and present how many markers come, no limits, I didn’t need to set anything. Are you sure you have more than 10 results even? You can also put a key to see if this is the problem <script src="http://maps.google.com/maps/api/js?key=SUA_CHAVE_AQUI"></script>.
– André Vicente
Worse than I’m sure, because the output has more than 10 addresses. And I’ve used with the key and in the same.
– KevinF
If you give a console.log(status) and console.log(result) inside callback and before if(status == 'OK') from Function addMarker it prints the 10 results or all?
– André Vicente
@André Vicente Continues to print all the results. But on the map only marks the top 10.
– KevinF
Guy takes a test, tries to create a delay between creating the points, you can use the
setTimeout
and gradually increase the time so that they do not start together, example: setTimeout(Function() {addMarker('RUA SAO FRANCISCO', ''); }, 200); hence the next one instead of 200 you put 400 and so it goes...– JuniorNunes
@Juniornunes Opa, it worked. Setei manual, it worked by giving a delay on each one. How do I now dynamic as it is in my code ?
– KevinF
@Kevin. F I need to know in which part you call and feeds the functions addMarker, can post the code?
– JuniorNunes
@Juniornunes I feed there in the first part of the code I posted just scroll down.
– KevinF
All right, I’ll answer!
– JuniorNunes