Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/11/2011, 14:54
ofertasdiarias
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
mapa google a traves de direccion ?

Hola que tal, ando en busca de su ayuda para lo siguiente :

TENGO UN FORMULARIO PARA EL ENVIO DE ANUNCIOS CLASIFICADOS Y LO QUE QUIERO O DESEO SI SE PUEDE LOGRAR ES QUE CUANDO LOS USUARIOS PONEN SU DIRECCION EN EL FORMULARIO, UNA VES QUE PUBLICAN EL MISMO APAREZCA EL MAPA DE GOOGLE MOSTRANDO EN QUE DIRECCION SE ENCUENTRAN?

Tengo este script : pero no logro hacerlo funcionar :

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin t&iacute;tulo</title>
<
script type="text/javascript">

var 
map;
var 
gdir;
var 
geocoder null;
var 
addressMarker;

function 
initialize() {
if (
GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("mapa_ruta"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
gdir = new GDirections(mapdocument.getElementById("direcciones"));
GEvent.addListener(gdir"load"onGDirectionsLoad);
GEvent.addListener(gdir"error"handleErrors);

setDirections("Huesca""Madrid""es");

}
}

function 
setDirections(fromAddresstoAddresslocale) {
gdir.load("from: " fromAddress " to: " toAddress,
"locale"locale });
}

function 
handleErrors(){
if (
gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("Dirección no disponible.\nError code: " gdir.getStatus().code);
else if (
gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " gdir.getStatus().code);
else if (
gdir.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " gdir.getStatus().code);
else if (
gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " gdir.getStatus().code);
else if (
gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " gdir.getStatus().code);
else 
alert("An unknown error occurred.");
}

function 
onGDirectionsLoad(){
}

</script>
  <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAI78oNLj04HLblSpiSpUnnhTk0GSbdWtDua7J5JFlJ4XKZ5ZTsRTNOAk_dd61WX8W7Swk98bbDPVIhg" type="text/javascript"></script>
</head>

<body onload="initialize(); onunload="GUnload()">
<div id="mapa" style="width: 710px; height: 300px; border: 4px solid #FF6600;"></div>

<script type="text/javascript">

var map = new GMap(document.getElementById("mapa")); map.addControl(new GLargeMapControl());

map.centerAndZoom(new GPoint(-8.4419, 43.2819), 8);
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.addControl(new GOverviewMapControl());
map.setMapType(G_NORMAL_MAP);

</script>
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value); return false" name="form">

Origen: <input type="text" size="25" id="fromAddress" name="from"/>

Destino: <input name="to" type="text" id="toAddress" size="25"/><br>
<input type="submit" name="Submit" value="Calcular Ruta"/>

</form> 
</body>
</html> 
DESDE YA MUCHAS GRACIAS A TODOS!!!!

Última edición por ofertasdiarias; 06/11/2011 a las 15:17