<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8" >
<!--[if gte IE 7]>
<link rel
="stylesheet" type
="text/css" media
="screen, projection" href
="css/style.css" /> <![endif]-->
<link rel
="stylesheet" media
="screen and (max-width:4100px)" href
="css/style.css"> <link media
="only screen and (max-device-width: 640px)" href
="css/movil.css" type
="text/css" rel
="stylesheet" />
<script type="text/javascript">
var contador = 0;
function funcion() {
for (var i=0;i < document.forms["comercios"].elements.length;i++) {
inpt = document.forms[0].elements[i];
if (inpt.checked) {
contador++;
}
}
if(contador >= 9) {
alert('Puedes crear tu ruta seleccionando un máximo de 8 establecimientos');
contador = 0;
return false;
}
}
</script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var infowindow;
var bound;
var map;
var geocoder; // importante incluirlo
(function () {
google
.maps
.Map
.prototype
.markers
= new Array();
google.maps.Map.prototype.addMarker = function (marker) {
this.markers[this.markers.length] = marker;
};
google.maps.Map.prototype.getMarkers = function () {
return this.markers
};
google.maps.Map.prototype.clearMarkers = function () {
if (infowindow) {
infowindow.close();
}
for (var i = 0; i < this.markers.length; i++) {
this.markers[i].set_map(null);
}
};
})();
function pintarDirecciones(puntos, latitudCliente, longitudCliente) {
bound = new google.maps.LatLngBounds(null);
//var latlng = new google.maps.LatLng(37.88909, -4.76125);
var latlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
//mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById("map"), myOptions);
geocoder = new google.maps.Geocoder() ;
function createMarker(name, latlng) {
var image = "http://www.dondelocompro.es/img/nuevas/home/ico_pincho.png";
var marker = new google.maps.Marker({ position: latlng, map: map, icon: image });
google.maps.event.addListener(marker, "click", function () {
if (infowindow) infowindow.close();
infowindow = new google.maps.InfoWindow({ content: name, width: 10, height: 50, maxWidth: 300 });
infowindow.set("isdomready", false);
infowindow.open(map, marker);
});
return marker;
}
function createMarker2(name, latlng) {
var marker = new google.maps.Marker({ position: latlng, map: map });
infowindow = new google.maps.InfoWindow({ content: name, width: 100, height: 100, maxWidth: 100 });
infowindow.set("isdomready", false);
infowindow.open(map, marker);
google.maps.event.addListener(marker, "click", function () {
//if (infowindow) infowindow.close();
infowindow = new google.maps.InfoWindow({ content: name, width: 100, height: 50, maxWidth: 100 });
infowindow.set("isdomready", false);
infowindow.open(map, marker);
});
return marker;
}
var arrayPuntos
= puntos
.split("#"); var marca;
for (i = 0; i < arrayPuntos.length; i++) {
var punto = arrayPuntos[i].toString();
var punto1
= punto
.split("$"); if (punto1.length > 2) {
var lat = punto1[1].replace(",", ".");
var lon = punto1[2].replace(",", ".");
//var point = new GPoint(lon, lat);
var latlng = new google.maps.LatLng(lat, lon);
var nombre = punto1[0].toString();
marca = map.addMarker(createMarker(nombre, latlng));
//var marker = createMarker(point, nombre);
bound.extend(latlng);
//bounds.extend(marker.getPoint());
//map.addOverlay(marker);
//map.centerAndZoom(point, 0);
}
//map.setCenter(point, 13);
}
if (latitudCliente != "" && longitudCliente != "") {
var latlngCliente = new google.maps.LatLng(latitudCliente.replace(",", "."), longitudCliente.replace(",", "."));
var nombreCliente = "Tu estás aquí.";
var marcaCliente = map.addMarker(createMarker2(nombreCliente, latlngCliente));
bound.extend(latlngCliente);
}
//alert("Hola0");
//map.setZoom(20);
if (arrayPuntos.length > 1) {
//alert(arrayPuntos.length.toString());
map.fitBounds(bound);
}
else {
//alert("Hola2");
//map.setZoom(10);
}
//Ajustar el zoom según los límites
//map.setZoom(map.getBoundsZoomLevel(bounds));
//Centrar el mapa de acuerdo a los límites
//map.setCenter(bounds.getCenter());
}
function codeAddress() {
geocoder = new google.maps.Geocoder();
var address = document.getElementById('address').value;
geocoder.geocode({
'address': address
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
infowindow = new google.maps.InfoWindow({
content:results[0].formatted_address + '<br/> Latitud: ' + results[0].geometry.location.lat() + '<br/> Longitud: ' + results[0].geometry.location.lng()});
infowindow.open(map, marker);
} else {
alert('Geocode no tuvo éxito por la siguiente razón: ' + status);
}
});
}
</script>
</head>
<body>
<form action="negocios.php" method="POST" name="comercios" onsubmit="return funcion();">
<div class="div_contenedor_fondo" >
<section>
<div class="back" style="padding-left:10px;" align="top">
<div class="mapa" style="padding-top:13px; height:100%;">
<div id="map" style="width:97%; border:1px solid #00AEF4; height: 435px; color:#333333; font-family: Verdana, Arial, Helvetica, sans-serif; "></div>
<table width="97%" class="formulario_arriba">
<tr><td colspan="2" style="background-color:#9DAAAE; padding:5px 0px 5px 10px;"> <span style="color:#ffffff;font-weight:bold; font-size:10pt;">Crea tu ruta</span></td></tr>
<tr><td>
<table style="background-color:#EDEDED;" width="100%" cellpadding="0" cellspacing="0" border="0" style=" padding-top:10px;">
<tr>
<td valign="middle" style="padding:5px 0px 0px 0px;">
<span style="color:Black;font-weight:bold;">Tu dirección</span>
</td>
<td valign="middle" align="left" style="padding:5px 0px 0px 0px;">
<input id="address" type="textbox" size="38" maxlength="80" value="" placeholder="Dirección" />
Latitud: <span id="x"></span>
<br />
Longitud: <span id="y"></span>
<input type="button" class="navi" value="Localizar" onclick="codeAddress();" >
</td>
</tr>
<tr>
<td ></td>
<td align="left" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%" valign="top" style="padding:5px 0px 0px 0px;">
<span style="color:Black;">Ejemplo:</span>
</td>
<td width="80%" align="left" valign="top" style="padding:5px 0px 0px 0px;">
<span style="color:Black; ">C/ camino de los sastres, n 1, Córdoba</span>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</td>
<td ></td>
</tr>
</table>
</td></tr>
</table>
</div>
</div>
</section>
</div>
<script type='text/javascript'> pintarDirecciones('<table border=0 cellpadding=0 cellspacing=0><tr><td align="left"><h3> MORENO Y RUIZ FERRETERIA, C.B. </h3></td></tr><tr><td align="left"><h4>Nos encontrarás en:<br><br>C/ Don Carlos Romero (local) <br></h4></td></tr></table>$37.891223$-4.7620716#','','');</script>
</form>
</body>
</html>