/************************************* ************** LEGAL ***************** La información contenida en este archivo es propiedad de Racetracker. Su copia, difusión o cualquier otro uso fuera del sitio web racetracker.es (sin la autorización del propietario) esta prohibido. Si tienes alguna duda, por favor escribenos un email a info@racetracker.es The information in this file is property of Racetracker. Copy, diffusion or any other use outside the website racetracker.es (without explicit authorization of the owner) is prohibited. if you have any questions, please send us an email to info@racetracker.es **************************************/ var usuarios = new Array(); var limites = new Array(0,0,0,0); var map; var marks = new Array(); var rutas = new Array(); function initialize() { // Cargamos las opciones del mapa var mapOptions = { zoom: 15, mapTypeId: google.maps.MapTypeId.SATELLITE, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, position: google.maps.ControlPosition.TOP_RIGHT }, zoomControlOptions: { position: google.maps.ControlPosition.RIGHT_TOP, style: google.maps.ZoomControlStyle.LARGE }, streetViewControl: false, center: new google.maps.LatLng(41.63753646888201, 1.6056549375000362) }; // Genero el mapa map = new google.maps.Map(document.getElementById('mapa_2d'),mapOptions); /* // Añado escuchadores al mapa google.maps.event.addListener(map, 'center_changed', function() { $("#chivatoC").html( map.getCenter().toString() ); }); google.maps.event.addListener(map, 'zoom_changed', function() { $("#chivatoZ").html( map.getZoom() ); }); */ // Cargo puntos en el mapa for (u = 0; u < usuarios.length; u++ ){ var temp = usuarios[u]; cargaPuntos(temp[0], temp[1], temp[2], temp[3], temp[4], u) } // Cargo KML con el perfil de Catalunya en el mapa var catUrl = 'http://voltacatalunya.cat/kml/catalunya2.kml'; var catLayer = new google.maps.KmlLayer({ url: catUrl //suppressInfoWindows: true, //preserveViewport: true }); //catLayer.setMap(map); } // Inicio el mapa google.maps.event.addDomListener(window, 'load', initialize); function cargaPuntos(usuario, icono, titulo, pos, color, i) { $.get("http://www.racetracker.es/app/demo/ajax.php?accion=carga&user=" + usuario, function(data){ var items = $.parseJSON(data); var ruta = new Array; var myLatlng, fecha, LatTemp, LngTemp; $.each(items, function(key, val) { // puntos myLatlng = new google.maps.LatLng(val['latitude'],val['longitude']); fecha = val['date']; ruta.push(myLatlng); LatTemp = val['latitude']; LngTemp = val['longitude']; }); rutas[i] = new google.maps.Polyline({ path: ruta, strokeColor: color, strokeOpacity: 1.0, strokeWeight: 4 }); rutas[i].setMap(map); // añado el marcador al último punto marks[i] = new MarkerWithLabel({ position: myLatlng, map: map, icon: 'http://www.racetracker.es/app/_iconos/' + icono, optimized: false, title: titulo, zIndex: pos, labelContent: ''+formatoFecha(fecha)+'', labelAnchor: new google.maps.Point(15, 50), labelClass: 'fechaGlobo', // the CSS class for the label labelStyle: {opacity: 1} }); // cambio el centro if ( usuarios.length > 1) { // N if ( limites[0] != 0) { if ( limites[0] < LatTemp ) { limites[0] = LatTemp; } } else { limites[0] = LatTemp; } // E if ( limites[1] != 0) { if ( limites[1] < LngTemp ) { limites[1] = LngTemp; } } else { limites[1] = LngTemp; } // S if ( limites[2] != 0) { if ( limites[2] > LatTemp ) { limites[2] = LatTemp; } } else { limites[2] = LatTemp; } // O if ( limites[3] != 0) { if ( limites[3] > LngTemp ) { limites[3] = LngTemp; } } else { limites[3] = LngTemp; } } else { map.setCenter(myLatlng); } if ( usuarios.length > 1 && (usuarios.length-1) == i) { var SO = new google.maps.LatLng(limites[2], limites[3]); var NE = new google.maps.LatLng(limites[0], limites[1]); var limitesMarcas = new google.maps.LatLngBounds(SO, NE); map.fitBounds(limitesMarcas); //alert("("+limites[2]+","+limites[3]+") - ("+limites[0]+","+limites[1]+")"); } usuarios[i][5] = fecha; }); } function formatoFecha(fecha){ fecha = fecha.replace(" ", "T"); var f = new Date(fecha); //return f.getDate() + "-" + (f.getMonth()+1) + "-" + f.getFullYear() + " " + f.getHours() + ":" + f.getMinutes() + "   "; var temp = ""; if ( f.getHours() < 10 ) { temp += "0"; } temp += f.getHours(); temp += ":"; if ( f.getMinutes() < 10 ) { temp += "0"; } temp += f.getMinutes(); return temp; } function recargaPuntos(){ // Cargo puntos en el mapa for (u = 0; u < usuarios.length; u++ ){ var temp = usuarios[u]; marks[u].setMap(null); //rutas[u].setMap(null); cargaPuntos(temp[0], temp[1], temp[2], temp[3], temp[4], u) } setTimeout(recargaPuntos,60000); } setTimeout(recargaPuntos,60000);