Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/10/2009, 17:50
Brian_91
 
Fecha de Ingreso: septiembre-2009
Mensajes: 27
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Google maps Mostrar globo de texto de marcador con un enlace <a href



Edite porque habia un error en los contadores "for".
Funciona asi, mando el id de las sucursales con un enlace <a href="mapa.php?suc0=1&suc1=28&sucs=1">link</a>

donde suc0 es la primer sucursal y el id es 1,suc1 segunda sucursal valor=2 la variable sucs contiene la cantidad de sucursales, yo lo muestro en un sexylightbox con jquery y no tengo problemas que me editen la url, en caso que editen la variable sucs daria error, igual se prodria pasar por $_SESSION[' sucs '].



Código PHP:
<html>

<head>





<script ***direccion de api mas key ***></script>
            
  
    <script type="text/javascript">

    //<![CDATA[
var map;
var marker;    
    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 1);
        map.addControl(new GMapTypeControl());
        map.addControl(new GSmallMapControl());
        map.addControl(new GScaleControl());
        map.addControl(new GOverviewMapControl());
        map.setMapType(G_NORMAL_MAP);
      }
      
      function addtag(point, address) {
        marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(address); } );
        return marker;
        }
         <?php
         
include_once("include/connection.php");
        
conectar();
        
        for(
$x=0$x<=$_GET['sucs'];$x++){
                
$sql="select sucid,succoordenadas,sucmarcadortexto,sucdir from sucursal where succoordenadas<>'empty' and sucid=".$_GET["suc$x"]; //coordenadas
                
$result=mysql_query($sql);
                
$filas=mysql_num_rows($result);
                
                while(
$row=mysql_fetch_assoc($result)){
                    
$coordenadas[]=$row['succoordenadas'];
                    
$marcador_texto[]=$row['sucmarcadortexto'];
                    
$direccion[]=$row['sucdir'];
                    
$sucid[]=$row['sucid'];
                    
                }
        }    
        
        for(
$i=0;$i<$filas;$i++){
                echo 
"var point2 = new GLatLng(".$coordenadas[$i].");\n";
                echo 
"var address2 = '<img src=\"imagenes/logo.jpg\" width=\"200\" height=\"50\" /><br/><font color=#A0E01E size=2><b>".$marcador_texto[$i]."</b></font><br /><font size=2>".$direccion[$i]."</font><br /><br />Teléfono: 928 222 345<br />';\n";
                echo 
"var marker2 = addtag(point2, address2);\n";
                echo 
"map.addOverlay(marker2);\n";
                echo
"GEvent.trigger(marker2,\"click\");\n";
        }
        
?>
      
    }
    
    <?php
        
    
for($z=0;$z<$filas;$z++){
        
$function preg_replace("/ /","a",$marcador_texto[$z]);
        
$functionpreg_replace("/0/","a",$function);
        
$functionpreg_replace("/1/","a",$function);
        
$functionpreg_replace("/2/","a",$function);
        
$functionpreg_replace("/3/","a",$function);
        
$functionpreg_replace("/4/","a",$function);
        
$functionpreg_replace("/5/","a",$function);
        
$functionpreg_replace("/6/","a",$function);
        
$functionpreg_replace("/7/","a",$function);
        
$functionpreg_replace("/8/","a",$function);
        
$functionpreg_replace("/9/","a",$function);
        
        
        echo
"function ".$function."() {\n";    
        echo
"map.setCenter(new GLatLng(".$coordenadas[$z]."), 10);\n";
        echo 
"var address2 = '<img src=\"imagenes/logo.jpg\" width=\"200\" height=\"50\" /><br/><font color=#A0E01E size=2><b>".$marcador_texto[$z]."</b></font><br /><font size=2>".$direccion[$z]."</font><br /><br />Teléfono: 928 222 345<br />';\n";
        
        
        echo
"map.openInfoWindow(map.getCenter(),(address2));\n";
        echo
"}\n";
        
//
    
}
    
?>
    
    //
    
    </script>
  </head>

  <body onload="initialize()" onunload="GUnload()" style="background-color:black;">
  <?php echo $marcador_texto[1]." ".$marcador_texto[0]; ?>
   <table>
       <tr>
            <td><h2 style="font:italic 24px Georgia, 'Times New Roman', Times, serif;color:#B8F84E;letter-spacing:-1px;">Hoteles</h2>
                <div style="width:150px;height:382px;overflow:auto;background-color:lightgrey;">
                <?php
                
for($t=0;$t<$filas;$t++){
                    
$var2 preg_replace("/ /","a",$marcador_texto[$t]);
                    echo
"<form action=\"\" onsubmit=\"".$var2."(); return false\">";
                        echo
"<input type=\"submit\" value=\"".$marcador_texto[$t]."\" style=\"border:1px solid lightgrey;background-color:lightgrey;color:white\" /><br>";
                    echo
"</form>";
                }
                
?>
                </div>
            </td>
            <td>
                    <div id="map_canvas" style="width: 750px; height: 430px" style=""></div>
            </td>
       </tr>
   </table>
   
  </body>
</html>

Última edición por Brian_91; 07/10/2009 a las 13:18