Pessoal tem um mapa onde preciso pontuar 100 pontos no mapa … mais quando tento fazer isso o google maps me lanca o erro OVER_QUERY_LIMIT. Tem alguma forma de contornar isso ? Sei que o google tem limite de request, mais nao consigo uma forma de solucionar esse problema .
estou fazendo da seguinte forma :
<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/js/Fluster2.packed.js"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function inicializarMapaGeral(){
var myOptions = {
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("mapa"), myOptions);
geocoder = new google.maps.Geocoder();
//Constroi uma instância do Fluster
var fluster = new Fluster2(map);
if ( geocoder ) {
var toNomes = new Array();
var toAdrress = new Array();
var toRecursos = new Array();
var toEspecialidades = new Array();
<%
//Parametros
String paramNomesPrestadores = (String) request.getParameter("nomesPrestadores");
String paramEspecialidadesPrestadores = (String) request.getParameter("especialidadesPrestadores");
String paramEnderecos = (String) request.getParameter("enderecos");
String paramRecursos = (String) request.getParameter("recursosTipos");
//Nome
paramNomesPrestadores = paramNomesPrestadores.replace("[", "");
paramNomesPrestadores = paramNomesPrestadores.replace("]", "");
paramNomesPrestadores = paramNomesPrestadores.trim();
String nomesPrestadores[] = paramNomesPrestadores.split(",");
//Especialidades
paramEspecialidadesPrestadores = paramEspecialidadesPrestadores.replace("[", "");
paramEspecialidadesPrestadores = paramEspecialidadesPrestadores.replace("]", "");
paramEspecialidadesPrestadores = paramEspecialidadesPrestadores.trim();
String especialidadesPrestadores[] = paramEspecialidadesPrestadores.split(",");
//Endereco
paramEnderecos = paramEnderecos.replace("[", "");
paramEnderecos = paramEnderecos.replace("]", "");
paramEnderecos = paramEnderecos.trim();
String enderecos[] = paramEnderecos.split(",");
//Tipo de Recurso
paramRecursos = paramRecursos.replace("[", "");
paramRecursos = paramRecursos.replace("]", "");
paramRecursos = paramRecursos.replace(" ", "");
paramRecursos = paramRecursos.trim();
String recursos[] = paramRecursos.split(",");
//Laço para percorrer os dois Arrays(Enderecos, Recursos)
for (int i = 0; i < enderecos.length; i++) {
String buf1 = (String) nomesPrestadores[i];
String buf2 = (String) enderecos[i];
String buf3 = (String) recursos[i];
String buf4 = (String) especialidadesPrestadores[i];
%>
toNomes[<%=i%>] = '<%=buf1%>';
toAdrress[<%=i%>] = '<%=buf2%>';
toRecursos[<%=i%>] = '<%=buf3%>';
toEspecialidades[<%=i%>] = '<%=buf4%>';
<%
}
%>
for (var i = 0; i<toAdrress.length; i++) {
var nome = toNomes[i];
var endereco = toAdrress[i];
var recurso = toRecursos[i];
var especialidade = toEspecialidades[i];
localizarEndereco(fluster, endereco, map, recurso, nome, especialidade);
}
}else{
alert("GeoCoder não identificado");
}
}
function localizarEndereco(fluster, endereco, map, recurso, nome, especialidade) {
geocoder.geocode( { 'address': endereco}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
icon = verificaIconeRecurso(recurso);
var marker = new google.maps.Marker({
map: map,
animation: google.maps.Animation.DROP,
icon: icon,
position: results[0].geometry.location
});
var html= '<html><b style="color: #0D7040">'+nome+'</b><br/><br/><b style="color: #E55300">'+especialidade+'</b><br/><br/>'+endereco.replace("-","<br/>")+'</html>';
var infowindow = new google.maps.InfoWindow({
content: html
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
// Set styles
fluster.styles = {
0: {
image: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/m1.png',
textColor: '#FFFFFF',
width: 53,
height: 52
},
10: {
image: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/m2.png',
textColor: '#FFFFFF',
width: 56,
height: 55
},
20: {
image: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/m3.png',
textColor: '#FFFFFF',
width: 66,
height: 65
}
};
// Adiciona pontos ao Fluster
fluster.addMarker(marker);
// Inicializa o Fluster
fluster.initialize();
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
function verificaIconeRecurso(recurso){
var image;
switch(recurso){
case "1":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/medico.png';
break;
case "2":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/hospital.png';
break;
case "3":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/laboratorio.png';
break;
case "4":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/clinica.png';
break;
case "5":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/pessoa-fisica.png';
break;
case "6":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/diagnostico.png';
break;
case "7":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/parceiro-comercial.png';
break;
case "8":
image = '<%=request.getContextPath()%>/corpo/2009-guia-medico-geral/icones/home-care.png';
break;
}
var icon = new google.maps.MarkerImage(image);
return icon;
}
</script>
</head>
<body onload="inicializarMapaGeral();">
<br/>
<h4>Localize esse profissional no mapa</h4>
<div id="mapa" style="height:600px;width:750px;border:1px solid #CCC;"></div>
</body>
</html>