Respuesta: Ubicar direcciones en Google Maps LOGRE SOLUCIONARLO, PERO NO ME MUESTRA TODAS LAS DIRECCIONES, ALGUIEN ME PODRIA APOYAR EN ESTO???... ES DECIR QUE CUANDO NO ENCUENTRA UNA DIRECCION, ENTONCES DEJA DE BUSCARLAS O DE COLOCARLAS... DONDE DIGO Q PASE A LA SIGUIENTE DIRECCION?... GRACIAS!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Autentia: dinos donde se encuentra tu empresa</title>
<script src="AQUI VA EL API GOOGLEMAPS"
type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
var address=new Array();
address[0] = "CAL. TRUJILLO 148, LIMA, PERU ";
address[1] = "AV. PEZET, GENERAL JUAN A. 1655, LIMA, PERU ";
address[2] = "CAL. 1 133, LIMA, PERU ";
address[3] = "CAL. COSSIO, JOSE G. 123, LIMA, PERU ";
address[4] = "PRQ. ACOSTA, CARLOS 229, LIMA, PERU ";
address[5] = "CAL. UGARTE, MANUEL 681, LIMA, PERU ";
address[6] = "PRQ. JOSE DE ACOSTA 161, LIMA, PERU ";
address[7] = "PAS. LOS CASTAOS 530, LIMA, PERU ";
address[8] = "AV. PORTILLO, CORONEL PEDRO 200, LIMA, PERU ";
address[9] = "AV. SANCHEZ CARRION, FAUSTINO 257, LIMA, PERU ";
address[10] = "AV. MIRO QUESADA 161, LIMA, PERU ";
address[11] = "JRN. TRUJILLO 126, LIMA, PERU ";
address[12] = "CAL. LOS CASTAOS 530, LIMA, PERU ";
address[13] = "CAL. MANNARELLI, LUIS 1149, LIMA, PERU ";
address[14] = "CAL. MANARELLI, LUIS 1149, LIMA, PERU ";
/*
address[0]="Av. Santa Fe 3181, Ciudad de Buenos Aires";
address[1]="Av. Corrientes 3247, Ciudad de Buenos Aires";
address[2]="Av. Corrientes 3889, Ciudad de Buenos Aires";
address[3]="Av. Santa Fe 3253, Ciudad de Buenos Aires";
address[4]="Av. Cabildo 2202, Ciudad de Buenos Aires";
address[5]="Av. Rivadavia 5216, Ciudad de Buenos Aires";
address[6]="Brasil 1253, Ciudad de Buenos Aires";
address[7]="Av. Melian 4630, Ciudad de Buenos Aires";
address[8]="Av. Rivadavia 6502, Ciudad de Buenos Aires";
address[9]="Av. Rivadavia 11626, Ciudad de Buenos Aires";
address[10]="Florida 296, Ciudad de Buenos Aires";
address[11]="Av. Corrientes 756, Ciudad de Buenos Aires";
address[12]="Valentin Gomez 2813, Ciudad de Buenos Aires";
address[13]="Av. Santa Fe 2401, Ciudad de Buenos Aires";
*/
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(-34.589229,-58.409836), 12);
// insertar los controles
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
}
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
// map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Lo sentimos, no se ha encontrado su direcci&ocute;n");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
map.setCenter(point, 12);
marker = new GMarker(point, {draggable: true});
GEvent.addListener(marker, "dragstart", function() {
map.closeInfoWindow();
});
GEvent.addListener(marker, "dragend", function() {
document.getElementById("punto").value = marker.getLatLng().toUrlValue();
marker.openInfoWindowHtml(place.address);
generateKML(place.address, marker.getLatLng().lng(), marker.getLatLng().lat());
});
map.addOverlay(marker);
marker.openInfoWindowHtml(place.address);
document.getElementById("punto").value = marker.getLatLng().toUrlValue();
generateKML(place.address, place.Point.coordinates[0], place.Point.coordinates[1]);
}
}
// showLocation() is called when you click on the Search button
// in the form. It geocodes the address entered into the form
// and adds a marker to the map at that location.
function showLocation() {
for (var i = 0; i < address.length; i++) {
geocoder.getLocations(address[i], addAddressToMap);
}
}
// findLocation() is used to enter the sample addresses into the form.
function findLocation(direccion, empresa ) {
document.forms[0].q.value = direccion;
document.getElementById("empresa").value = empresa;
showLocation();
}
function generateKML(description, lng, lat){
document.getElementById("kml").value = '';
var kml = '<?xml version="1.0" encoding="UTF-8"?>\n';
kml = kml + '<kml xmlns="http://earth.google.com/kml/2.2">\n';
kml = kml + '<Placemark>\n';
kml = kml + '\t<name>' + document.getElementById("empresa").value + '</name>\n';
kml = kml + '\t<description>' + description + '</description>\n';
kml = kml + '\t<Point><coordinates>' + lng + ',' + lat + ',0</coordinates></Point>\n';
kml = kml + '</Placemark>\n';
kml = kml + '</kml>\n'
document.getElementById("kml").value = kml;
}
</script>
</head>
<body onload="initialize()">
<a href="javascript:void(0)" onclick="findLocation('Avenida de Castilla 2, San Fernando de Henares', 'Autentia');return false;">Ir a Autentia</a><br/>
<p>
<b>Escribe el nombre de tu empresa:</b>
<input id="empresa" type="text" size="40"/>
</p>
<form action="#" onsubmit="showLocation(); return false;">
<p>
<b>Escribe aquí tu dirección:</b>
<input type="text" name="q" value="" class="address_input" size="40" />
<input type="submit" name="find" value="Buscar" />
</p>
</form>
<div id="map_canvas" style="width: 800px; height: 600px"></div>
<p>
<b>Coordenadas:</b>
<input id="punto" type="text" size="40"/>
</p>
</body>
</html> |