Foros del Web » Creando para Internet » Diseño web »

Combinar scripts

Estas en el tema de Combinar scripts en el foro de Diseño web en Foros del Web. Hola amigos, necesito ayuda para entregar un trabajo. Entiendo que es dificil; pero igual lo pregunto aquí porque no doy con ningun grupo en español ...
  #1 (permalink)  
Antiguo 17/04/2010, 09:09
 
Fecha de Ingreso: septiembre-2009
Mensajes: 87
Antigüedad: 14 años, 7 meses
Puntos: 1
Combinar scripts

Hola amigos, necesito ayuda para entregar un trabajo. Entiendo que es dificil; pero igual lo pregunto aquí porque no doy con ningun grupo en español de programadores de API google: lo que intento es mezclar dos conceptos de presentar un mapa google dentro de un formulario. Lo que necesito es ingresar el siguiente código de geolocalización extraido de un ejemplo en la página de google:

Código:
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script>
    <script type="text/javascript">

    var map = null;
    var geocoder = null;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        geocoder = new GClientGeocoder();
      }
    }

    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
    </script>
Pero que funcione combinadamente con el script que ya he creado con marcadores arrastrables.

Código:
Latitude: <input class="required" type="text" name="latitude" id="latitude" value="53.34870686020199" /> 
Longitude: <input class="required" type="text" name="longitude" id="longitude" value="-6.267356872558594" />


<br /><br />
<div id="map" style="width: 600px; height: 420px"></div>

<head>

<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA1v1vriVofe2dZK4B47fQZhQNk9jlHToEF3uv7PmMbUMZCienoBSZCfMgFLPA2xQIffZ0UKndKQPYbw"></script>

<script type="text/javascript">	

<!--
if (GBrowserIsCompatible()) 
{
	// crear mapas y controles
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());        
	map.addControl(new GMapTypeControl());
		
    // establecer el centro del mapa
	var centrePoint = new GLatLng('-38.272688535980954', '-65.830078125');
	map.setCenter(centrePoint, 4);	
	geocoder = new GClientGeocoder();
	geocoder.setBaseCountryCode("ar");
		
	// agregar un marcador arrastrable
	var marker = new GMarker(centrePoint, {draggable: true});
	map.addOverlay(marker);
	
	// agregar escucha de marcador arrastrable
	GEvent.addListener(marker, "dragend", function() {
		var point = marker.getPoint();
		map.panTo(point);
		document.getElementById("latitude").value = point.lat();
		document.getElementById("longitude").value = point.lng();
    });
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
    <form action="#" onsubmit="showAddress(this.address.value); return false">
      <p>
        <input type="text" size="60" name="address" value="" />
        <input type="submit" value="Localizar este domicilio" />
      </p>
      <div id="map_canvas" style="width: 500px; height: 300px"></div>
    </form>
    </body>
</html>
El problema es que, como verán en el segundo código, no sé cómo incorporar la función de direcciones o combinar ambos script para obtener un mapa que acepte variables desde la url de otro formulario y me permita sintonizar esta dirección predeterminada con marcadores arrastrables.

Se entiende?

Muchas gracias por sus comentarios...

Etiquetas: combinar, scripts
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 04:29.