Foros del Web » Programando para Internet » Javascript »

Llamar un archivo de texto en google maps

Estas en el tema de Llamar un archivo de texto en google maps en el foro de Javascript en Foros del Web. Que tal soy nuevo en el foro, alguien me podria ayudar a como utilizar un archivo txt en google maps, lo que hago es trazar ...
  #1 (permalink)  
Antiguo 25/05/2012, 18:29
 
Fecha de Ingreso: abril-2012
Ubicación: México
Mensajes: 3
Antigüedad: 12 años
Puntos: 1
Llamar un archivo de texto en google maps

Que tal soy nuevo en el foro, alguien me podria ayudar a como utilizar un archivo txt en google maps, lo que hago es trazar rutas en el mapa escribiendo las coordenadas en la funcion directions.load(), pero en lugar de escribirlas directamente en la funcion quiero guardar las coordanadas en un .txt y llamarlas, se que el archivo de texto lo llamo con <script src="rutas.txt"></script>
pero ahora lo que quiero es llamar a las rutas del .txt en la funcion.

Codigo GoogleMaps:
Código Javascript:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  4.   <head>
  5.     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  6.     <title>Google Maps JavaScript API Example: Event Context</title>
  7.     <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
  8.             type="text/javascript"></script>
  9. <script src="rutas.txt"></script>
  10.     <script type="text/javascript">
  11.     var map;
  12.     var directionsPanel;
  13.     var directions;  
  14.    
  15.     function initialize() {
  16.       if (GBrowserIsCompatible()) {
  17.         map = new GMap2(document.getElementById("map_canvas"));
  18.         directionsPanel = document.getElementById("my_textual_div");
  19.         map.setCenter(new GLatLng(19.0452, -98.1975), 13);
  20.         directions = new GDirections(map, directionsPanel);
  21.         directions.load("from: 19.073260673918124, -98.2043295353651 to: 19.06999624726789, -98.20791766047478 to: 19.064128229593183, -98.1915333867073 to: 19.0257550617554, -98.20219047367573 to: 18.97479962658195, -98.19917231798172");
  22.         GEvent.addListener(map, "moveend", function() {
  23.           var center = map.getCenter();
  24.           document.getElementById("message").innerHTML = center.toString();
  25.          
  26.     });
  27.       }
  28.     }
  29.     </script>
  30.   </head>
  31.   <body onload="initialize()" onunload="GUnload()">
  32.     <div id="map_canvas" style="width: 500px; height: 300px"></div>
  33.     <div id="message"></div>
  34.   </body>
  35. </html>

rutas.txt:
Código Archivo de Texto:
Ver original
  1. coordenada_x1="19.073260673918124";
  2. coordenada_y1="-98.2043295353651";
  3.  
  4. coordenada_x2="19.06999624726789";
  5. coordenada_y2="-98.20791766047478";
  6.  
  7. coordenada_x3="19.064128229593183";
  8. coordenada_y3="-98.1915333867073";
  9.  
  10. coordenada_x4="19.0257550617554";
  11. coordenada_y4="-98.20219047367573";
  12.  
  13. coordenada_x5="18.97479962658195";
  14. coordenada_y5="-98.19917231798172";

Etiquetas: funcion, google, html, maps
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 12:14.