Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá,
Corri pelo forum procurando uma solução para retornar os dados cadastrados em meu access em forma de marcadores no mapa.
Encontrei uma solução onde exibe o marcador de acordo com os dados cadastrados.
O problema é que não estou acertando como implementar um loop para varrer todos os dados do banco e colocar quantos marcadores forem necessários no mesmo mapa...
Aqui está o código funcionando, mas só mostra o último registro/marcador:
<!-- #include file="gmaps_conexao.asp"-->
<% Session.LCID = 1046 %>
<%
call abre_conectar
strSQL = "SELECT * FROM fatos WHERE status ='publicado'"
Set rstSearch = cnn.Execute(strSQL)
While Not rstSearch.EOF
UrlMapa = rstSearch("cidade")&rstSearch("uf")&rstSearch("pais")
FTexto = rstSearch("texto")
rstSearch.MoveNext
Wend
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>Google Maps Javascript API Example</title>
<script src="[http://maps.google.com/maps?file=api&v=2&key=CHAVE](http://maps.google.com/maps?file=api&v=2&key=CHAVE)
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[var geocoder
// showLocation() is called when you click on the Search button
// in the form. It geocodes the address entered into the form
// and adds a marker to the map at that location.
function showLocation() {
var address = '<%=UrlMapa%>';
geocoder.getLocations(address, addAddressToMap);
}
function load() {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(-26.992970522417455,-48.634071350097656), 5);
geocoder = new GClientGeocoder();
map.setMapType(map.getMapTypes()[0]);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
}
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
//map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Endereço incorreto ou inexistente");
} else {
var num_resultados = response.Placemark.length;
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml('<span style="font:11px tahoma;">' + place.address + '<br><br><b>Fato: </b><br><%=FTexto%></span>');
}
}
function findLocation(address) {
//document.forms[0].q.value = address;
showLocation();
}
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
// marker.openInfoWindowHtml("teste");
});
return marker;
}
//]]>
</script>
</head>
<body onload="load(); showLocation();">
<div id="map" style="width: 500px; height: 300px"></div>
<%
call fecha_conectar
Set rstSearch = Nothing
%>
</body>
</html>
[http://forum.imasters.com.br/public/style_emoticons/](http://forum.imasters.com.br/public/style_emoticons/)default/ermm.gifCarregando comentários...