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í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(map, document.getElementById("direcciones"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
setDirections("Huesca", "Madrid", "es");
}
}
function setDirections(fromAddress, toAddress, locale) {
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&v=2&sensor=true_or_false&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>