Foros del Web » Programando para Internet » PHP »

Api google maps

Estas en el tema de Api google maps en el foro de PHP en Foros del Web. Hola estoy con un problemita me lei todo elarticulo de google api https://developers.google.com/maps/a...lajax_v3?hl=es Donde un archivo " archivouno.php" html o php levanta otro xml que ...
  #1 (permalink)  
Antiguo 06/02/2014, 10:24
 
Fecha de Ingreso: enero-2012
Mensajes: 224
Antigüedad: 12 años, 3 meses
Puntos: 1
Api google maps

Hola estoy con un problemita me lei todo elarticulo de google api https://developers.google.com/maps/a...lajax_v3?hl=es

Donde un archivo " archivouno.php" html o php levanta otro xml que es generado por php " archivodos.php"


El tema es que el "archivouno.php" con tiene la sentencia para generar el XML y yo quiero que esta sea dinamica segun el ID

Pero no puedo lograrlo , hay alguna forma de fusionar ambos archivos? o alguna otra solucion?

gracias


Archivouno.php

Código PHP:
<?php require_once('dbconect.php'); ?>
<?php
$dom 
= new DOMDocument("1.0");
$node $dom->createElement("markers");
$parnode $dom->appendChild($node); 

// Opens a connection to a MySQL server

$connection=mysql_connect ('localhost'$username$password);
if (!
$connection) {  die('Not connected : ' mysql_error());} 

// Set the active MySQL database

$db_selected mysql_select_db($database$connection);
if (!
$db_selected) {
  die (
'Can\'t use db : ' mysql_error());


// Select all the rows in the markers table
$colname_suministros "1";
if (isset(
$_GET['id'])) {
  
$colname_suministros = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
$query sprintf("SELECT * FROM reclamos WHERE id= %s") , $colname_suministros);;
$result mysql_query($query);
if (!
$result) {  
  die(
'Invalid query: ' mysql_error());


header("Content-type: text/xml"); 

// Iterate through the rows, adding XML nodes for each

while ($row = @mysql_fetch_assoc($result)){  
  
// ADD TO XML DOCUMENT NODE  
  
$node $dom->createElement("marker");  
  
$newnode $parnode->appendChild($node);   

 
$newnode->setAttribute("name"$row['nombre']);
  
$newnode->setAttribute("address"$row['direccion']);
  
$newnode->setAttribute("lat"$row['latitud']);
  
$newnode->setAttribute("lng"$row['longitud']);
  
$newnode->setAttribute("type"$row['area']);


echo 
$dom->saveXML();
?>

archivodos.php

Código PHP:
<!DOCTYPE html >
  <
head>
    <
meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <
meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <
title>PHP/MySQL Google Maps Example</title>
    <
script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    //<![CDATA[

    var customIcons = {
      restaurant: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png'
      },
      bar: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png'
      }
    };

    function load() {
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(-34.8321388, -58.3700543),
        zoom: 12,
        mapTypeId: 'roadmap'
      });
      var infoWindow = new google.maps.InfoWindow;

      // Change this depending on the name of your PHP file
      downloadUrl("ver.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var name = markers[i].getAttribute("name");
          var address = markers[i].getAttribute("address");
          var type = markers[i].getAttribute("type");
          var point = new google.maps.LatLng(
              parseFloat(markers[i].getAttribute("lat")),
              parseFloat(markers[i].getAttribute("lng")));
          var html = "<b>" + name + "</b> <br/>" + address;
          var icon = customIcons[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon
          });
          bindInfoWindow(marker, map, infoWindow, html);
        }
      });
    }

    function bindInfoWindow(marker, map, infoWindow, html) {
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    }

    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }

    function doNothing() {}

    //]]>

  </script>

  </head>

  <body onload="load()">
    <div id="map" style="width: 500px; height: 300px"></div>
  </body>

</html> 

Etiquetas: api, google, html, maps, mysql, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:48.