Estoy programando una aplicacion que lleva mapas de google, logro que lea las direcciones de una base de datos y con un ciclo vaya colocando los markers. Pero aleatoriamente decide no encontrar algunos puntos, a veces si los encuentra y aveces no. que puede ser?
les dejo el codigo:
Código:
Gracias! <? include("includes/dbconnection.php"); ?><!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"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>KB</title> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-1374188-2"; urchinTracker(); </script> <link href="css/css.css" rel="stylesheet" type="text/css" /> <script src="http://maps.google.com/maps?hl=en&file=api&v=3&key=ABQIAAAA74C-57tIoDap1RRDo0PVYBS7vtL5MwZOtmmR-bW9l2O2WZIwRRR8BT3Knbb5pjBSuIkwfU10JF7J1Q" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); var geocoder = new GClientGeocoder(); map.setUIToDefault(); var address = "<? echo $_POST['address2']." ".$_POST['city2'].", ".$_POST['state2']." ".$_POST['zipcode']; ?>"; geocoder.getLatLng(address, function showLocation(point) { if (!point) { alert(address + " no encontrado."); } else { var iconoMarca = new GIcon(G_DEFAULT_ICON); iconoMarca.image = "you.png"; var tamanoIcono = new GSize(35,12); iconoMarca.iconSize = tamanoIcono; var tamanoSombra = new GSize(0,0); iconoMarca.shadowSize = tamanoSombra; iconoMarca.iconAnchor = new GPoint(11, 16); map.setCenter(point, 18); var marker = new GMarker(point, iconoMarca); map.addOverlay(marker); var photo = "http://www.misitio.com/widget.png"; var label = "<div align='left'><span style='font-size: 8pt; font-family: verdana'><table width=300><tr><td> <img src=" + photo + " widht=80 height=80 alt=KB border=0 /></td><td> <span class=title> " + nombre + "</span><br><strong>Your Address is: </strong> <span class=place_description>" + address + "</span> <br><br><br></td></tr></table></div>"; GEvent.addListener(marker, "click", function showLabel() { marker.openInfoWindowHtml(label); } ); } } ); <? $sqls = "select * from providers "; //Resultado de la consulta $resultados=mysql_query($sqls,$db); while($myrow = mysql_fetch_array($resultados)) { $IDp=$myrow["ID"]; $name=$myrow["name"]; $email=$myrow["email"]; $address=$myrow["address"]; $city=$myrow["city"]; $state=$myrow["state"]; $zipcode=$myrow["zipcode"]; $status=$myrow["status"]; if($status=='a') { $icon="pin.png"; }else{ $icon="pinun.png";} $dir=$address." ".$city.", ".$state." ".$zipcode; ?> address = "<?= $dir; ?>"; geocoder.getLatLng(address, function showLocation(point) { if (!point) { alert(address + " unlocated."); } else { var iconoMarca = new GIcon(G_DEFAULT_ICON); iconoMarca.image = "<? echo $icon; ?>"; var tamanoIcono = new GSize(30,30); iconoMarca.iconSize = tamanoIcono; var tamanoSombra = new GSize(0,0); iconoMarca.shadowSize = tamanoSombra; iconoMarca.iconAnchor = new GPoint(11, 16); var marker = new GMarker(point, iconoMarca); map.addOverlay(marker); var nombre = "<? echo $name; ?>"; var photo = "http://www.misitio.com/widget.png"; var ID = "IDp"; var label = "<div align='left'><span style='font-size: 8pt; font-family: verdana'><table width=300><tr><td> <img src=" + photo + " widht=80 height=80 alt=KB border=0 /></td><td> <span class=title> " + nombre + "</span><br><strong>Your Address is: </strong> <span class=place_description>" + address + "</span> <br><br><br></td></tr></table></div>"; GEvent.addListener(marker, "click", function showLabel() { marker.openInfoWindowHtml(label); } ); } } ); <? } ?> } } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <table align="center"> <tr> <td align="center"> <div id="map" style="width: 900px; height: 600px"></div> <td> </tr> </table> </body> </html>