Files
SIG/GPS/RastreoTrayectos.aspx

680 lines
30 KiB
Plaintext

<%@ Page Title="" Language="VB" MasterPageFile="~/SiteGPS.master" AutoEventWireup="false" CodeFile="RastreoTrayectos.aspx.vb" Inherits="GPS_RastreoTrayectos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style type="text/css">
.ADScroller-body {
max-height: 400px;
}
.dataTables_scrollHeadInner > table {
background: lightgray;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
table.dataTable th.focus, table.dataTable td.focus {
outline: 3px solid #3366ff00;
outline-offset: -1px;
}
.CustomSpinner {
position: fixed;
background-image: url(/Imagenes/Loading.gif);
background-repeat: no-repeat, repeat;
background-size: contain;
top: 60px;
right: 25px;
z-index: 500000;
height: 40px;
width: 40px;
}
/*.page-head {
display: none;
}
.page-breadcrumb .breadcrumb {
display: none;
}
#barradenavegacion {
display:none;
}*/
#showdiv1 {
left: 0 !important;
width: 100% !important;
}
#ShowDiv3:hover {
line-height: 34px !important;
-webkit-transition: line-height ease 1s;
-moz-transition: line-height ease 1s;
-o-transition: line-height ease 1s;
transition: line-height ease 1s;
}
#map {
position: fixed !important;
}
.pac-container.pac-logo {
z-index: 100000;
}
#iw-container {
margin-bottom: 10px;
}
#iw-container .iw-title {
font-family: 'Open Sans Condensed', sans-serif;
font-size: 22px;
font-weight: 400;
padding: 10px;
background-color: #48b5e9;
color: white;
margin: 0;
border-radius: 2px 2px 0 0;
}
#iw-container .iw-content {
font-size: 13px;
line-height: 18px;
font-weight: 400;
margin-right: 1px;
padding: 15px 5px 20px 15px;
max-height: 140px;
overflow-y: auto;
overflow-x: hidden;
}
.iw-content img {
float: right;
margin: 0 5px 5px 10px;
}
.iw-subTitle {
font-size: 16px;
font-weight: 700;
padding: 5px 0;
}
.iw-bottom-gradient {
position: absolute;
width: 326px;
height: 25px;
bottom: 10px;
right: 18px;
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
}
.modal.fade:not(.in).left .modal-dialog {
-webkit-transform: translate3d(-25%, 0, 0);
transform: translate3d(-25%, 0, 0);
}
.modal.fade:not(.in).right .modal-dialog {
-webkit-transform: translate3d(25%, 0, 0);
transform: translate3d(25%, 0, 0);
}
.modal.fade:not(.in).bottom .modal-dialog {
-webkit-transform: translate3d(0, 25%, 0);
transform: translate3d(0, 25%, 0);
}
/* Alternative Angles */
.modal.fade:not(.in).top-left .modal-dialog {
-webkit-transform: translate3d(-25%, -25%, 0);
transform: translate3d(-25%, -25%, 0);
}
.modal.fade:not(.in).top-right .modal-dialog {
-webkit-transform: translate3d(25%, -25%, 0);
transform: translate3d(25%, -25%, 0);
}
.modal.fade:not(.in).bottom-left .modal-dialog {
-webkit-transform: translate3d(-25%, 25%, 0);
transform: translate3d(-25%, 25%, 0);
}
.modal.fade:not(.in).bottom-right .modal-dialog {
-webkit-transform: translate3d(25%, 25%, 0);
transform: translate3d(25%, 25%, 0);
}
.minicolors {
position: relative;
MARGIN-TOP: 10PX;
WIDTH: 20%;
}
table.dataTable,
table.dataTable th,
table.dataTable td {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.dataTables_scrollBody > .dataTable > thead {
display: none !important;
}
tr td:nth-child(4) {
text-align: center;
}
.form-horizontal .control-label {
text-align: left;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UpFiltros" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:Timer runat="server" ID="TimmerRefresh" Enabled="false" Interval="30000" OnTick="TimmerRefresh_Tick"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
<div id="map"></div>
<div class="modal fade bottom in" style="bottom: unset; z-index: 539" id="h">
<div class="modal-dialog" style="position: fixed; bottom: 0; margin: 0px,0px,0px,0px; width: 100%; padding: 0px, 0px, 0px, 0px; border-style: solid; border-color: rgb(68, 77, 88); z-index: 539;">
<div class="modal-content">
<div class="modal-body" style="padding: 5px;">
<asp:UpdatePanel runat="server" ID="UPGV" UpdateMode="Conditional">
<ContentTemplate>
<div id="DvPaginacion" runat="server" class="row" visible="false">
<div class="col-md-11">
<asp:Label ID="LblRegistros" runat="server" Style="display: inline-block;"></asp:Label>
</div>
<div class="col-md-1" style="display: inline-block; position: relative">
<asp:HiddenField ID="HdnIndexPage" runat="server" ClientIDMode="Static" Value="0" />
<asp:LinkButton ID="btnPagePrev" runat="server" Style="vertical-align: top;" Text="<i class='fa fa-angle-left' style='font-size:24px' aria-hidden='true'></i> Anterior" OnClick="btnPagePrev_Click" Enabled="false" />
<asp:LinkButton ID="btnPageNext" runat="server" Style="vertical-align: top;" Text="Siguiente <i class='fa fa-angle-right' aria-hidden='true' style='font-size:24px'></i>" OnClick="btnPageNext_Click" />
</div>
</div>
<asp:GridView ID="GvBarra" runat="server" GridLines="None" PageSize="1000" AllowPaging="true" AllowCustomPaging="true" DataKeyNames="Vehiculo, Posicion,Fecha,Velocidad, CveDispositivo" CssClass="table table-striped table-advance table-hover Widthall ADScrollPaginator2" data-sort="true" data-height="150px;" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False" EmptyDataText="No se encontraron registros">
<Columns>
<asp:BoundField DataField="Vehiculo" ItemStyle-Width="15%" HeaderText="Vehículo" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="Fecha" ItemStyle-Width="15%" HeaderText="Fecha Reporte" ItemStyle-HorizontalAlign="center" />
<asp:TemplateField ItemStyle-Width="30%" HeaderText="Dirección" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:Literal runat="server" Text="Haga click para ver Dirección" ID="ltlDireccion"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TiempoDetenido" ItemStyle-Width="25%" DataFormatString="{0} Minutos" HeaderText="Tiempo Detenido" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="Evento" ItemStyle-Width="25%" HeaderText="Eventos" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="Velocidad" ItemStyle-Width="10%" DataFormatString="{0:N2} KM/H" HeaderText="Velocidad" ItemStyle-HorizontalAlign="center" />
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="HdnDireccionRow" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NextPrevious" Visible="true" Position="Top" />
</asp:GridView>
<asp:HiddenField ID="HdnIndexGvBarra" runat="server" ClientIDMode="Static" Value="-1" />
<asp:HiddenField ID="HdnTextFilter" runat="server" ClientIDMode="Static" Value="" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="JS" runat="Server">
<script src="<%= String.Format("https://maps.googleapis.com/maps/api/js?key={0}&libraries=places", Extensiones.GOOGLE_MAPS_API_KEY) %>"</script>
<script src="../Metronic/assets/global/plugins/datatables2/datatables.min.js"></script>
<script src="../Metronic/assets/global/plugins/datatables2/extensions/Scroller/js/dataTables.scroller.js"></script>
<script src="../Metronic/assets/global/plugins/datatables2/extensions/KeyTable/js/dataTables.keyTable.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
initMap();
});
var image = '/Imagenes/rsz_11rsz_car.png';
var geocoder;
var map;
var directionsService;
var directionsDisplay;
var polylinesRoute = [];
var directionsDisplayArray = [];
var lastOpenedInfoWindow;
var retorno;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 24.6345, lng: -102.5528 },
zoom: 6
});
var ShowDiv1 = document.createElement('div');
var ShowDivControl = new ShowDiv(ShowDiv1, map);
ShowDiv1.index = 1;
ShowDiv1.id = "showdiv1"
map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(ShowDiv1);
geocoder = new google.maps.Geocoder();
google.maps.event.addListener(map, "click", function (event) {
closeLastOpenedInfoWindow();
});
directionsService = new google.maps.DirectionsService;
directionsDisplay = new google.maps.DirectionsRenderer;
directionsDisplay.setOptions({ suppressMarkers: true });
directionsDisplay.setMap(map);
}
var polylines = [];
var coordspoly = [];
var geoRutasHistoricas = [];
function creaPolyline(coords, color, info, lastcoord, nomequipo, Imagen, valueEquipo, Continuo) {
var lineSymbol = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
strokeWeight: 1,
strokeOpacity: 1,
scale: 3,
fillOpacity: 0.6
};
var polyline = new google.maps.Polyline({
path: coords,
strokeColor: color,
strokeOpacity: 0.6,
strokeWeight: 6,
fillOpacity: 0.35,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '80px'
}]
});
polyline.setMap(map);
polylines.push(polyline);
if (coordspoly.length <= 0 && typeof (Continuo) === "undefined") {
FitBoundsToCoords(coords);
} else {
coordspoly.push(coords[coords.length - 1]);
}
if (lastcoord != "") {
var geo = {
NombreEquipo: nomequipo,
ValueEquipo: valueEquipo,
UltimaPos: lastcoord,
Cordenadas: coords
};
geoRutasHistoricas.push(geo);
CreaMarcador(lastcoord, nomequipo, info, Imagen);
ConsultaDireccionesRutasHistoricas(geo);
}
}
function closeLastOpenedInfoWindow() {
if (lastOpenedInfoWindow) {
lastOpenedInfoWindow.close();
}
}
function fitBoundsToVisibleMarkers() {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
if (markers[i].getVisible()) {
bounds.extend(markers[i].getPosition());
}
}
map.fitBounds(bounds);
}
function ShowDiv(controlDiv, map) {
// Set CSS for the control border.
var controlUI = document.createElement('div');
controlUI.style.backgroundColor = '#444d58';
controlUI.style.border = '2px solid #444d58';
controlUI.style.borderRadius = '3px';
controlUI.style.width = '100%'
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
controlUI.style.cursor = 'pointer';
controlUI.style.marginRight = '5px';
controlUI.style.marginTop = '5px';
controlUI.style.marginBottom = '0px';
controlUI.style.textAlign = 'center';
// controlUI.title = 'Click para borrar el último punto dibujado';
controlDiv.appendChild(controlUI);
// Set CSS for the control interior.
var controlText = document.createElement('div');
controlText.style.color = '#ebebeb';
controlText.id = "ShowDiv3"
controlText.style.fontFamily = ' "Open Sans", sans-serif; ';
controlText.style.fontSize = '14px';
controlText.style.lineHeight = '20px';
controlText.style.paddingLeft = '5px';
controlText.style.paddingRight = '5px';
controlText.innerHTML = '<i class="fa fa-angle-up" aria-hidden="true"></i>';
controlUI.appendChild(controlText);
// Setup the click event listeners: simply set the map to Chicago.
controlUI.addEventListener('click', function () {
FNShowDiv();
});
}
function FNShowDiv() {
if (open === false) {
//$("#ChkSeguimiento").appendTo("#DivSeguimiento");
//$("#ChkSeguimiento").appendTo("#DivSeguimiento");
$("#h").modal()
$("#ShowDiv3").css("line-height", "34px")
open = true
$("#ShowDiv3").html('<i class="fa fa-angle-down" aria-hidden="true"></i>')
setTimeout(function () {
$('.table.ADScrollPaginator2').DataTable().draw();
}, 150);
if ($("#HdnOpcion").val() === 'All' || $("#HdnOpcion").val() === 'Idle' || $("#HdnOpcion").val() === 'Ralenti') {
$('#btnPlay').css('display', '');
$('#btnPrintExcel').css('display', '');
$('#btnPrintPDF').css('display', '');
$("#btnPlay").click(function () {
pause = !pause;
if (pause) {
stopTimeout();
} else {
if (startPlay) {
startPlay = false;
Play();
} else {
Play();
}
}
if ($('#btnPlay > i').hasClass("fa-pause")) {
$('#btnPlay > i').removeClass("fa-pause").addClass("fa-play");
} else if ($('#btnPlay > i').hasClass("fa-play")) {
$('#btnPlay > i').removeClass("fa-play").addClass("fa-pause");
}
});
$("#btnPrintExcel").click(function () {
var s;
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_BtnImprimirEX")
});
$("#btnPrintPDF").click(function () {
var s = "";
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_btnImprimir")
});
} else if ($("#HdnOpcion").val() === 'Speed') {
$('#btnPrintExcel').css('display', '');
$('#btnPrintPDF').css('display', '');
$("#btnPrintExcel").click(function () {
var s;
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_BtnImprimirEX")
});
$("#btnPrintPDF").click(function () {
var s = "";
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_btnImprimir")
});
} else if ($("#HdnOpcion").val() === 'Last') {
$('#btnPrintExcel').css('display', '');
$("#btnPrintExcel").click(function () {
var s;
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_BtnImprimirEX");
});
}
} else {
$("#h").modal('hide')
$("#ShowDiv3").css("line-height", "20px")
open = false
$("#ShowDiv3").html('<i class="fa fa-angle-up" aria-hidden="true"></i>')
}
}
function GvBarraPaginator() {
$('.table.PaginarGV').each(function () {
var Tthis = $(this);
if (!$.fn.DataTable.isDataTable(Tthis) && Tthis.find("th").length > 0) {
Tthis.prepend(("<thead></thead>"));
Tthis.find('thead').append($("#C_GvBarra").find("tr:first"));
var table = Tthis.DataTable({
deferRender: true,
deferLoading: 100,
scrollY: 130,
scrollCollapse: true,
scroller: {
displayBuffer: 20
},
ordering: true
});
var tkeys = new $.fn.dataTable.KeyTable(table, {
// options
});
var parent = Tthis.parent().parent().parent();
$('.dataTables_scrollHeadInner > .table.ADScrollPaginator2').find('th').addClass('importantth');
parent.find(".dataTables_paginate").css("display", "none");
parent.find(".dataTables_length").css("display", "none");
}
});
}
$(document).ready(function () {
GvBarraPaginator();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
$("#C_GvBarra_filter > div > input").on("keypress", function (e) {
HdnTextFilter.value = $(this).val() + String.fromCharCode(e.which);
});
}
});
var markers = [];
function CreaMarcador(coords, nomEquipo, ContentString, imagen) {
if (typeof imagen === 'undefined') { imagen = image; }
var markerIcon = {
url: imagen,
labelOrigin: new google.maps.Point(26, 43)
};
var marker = new google.maps.Marker({
position: coords,
title: nomEquipo,
map: map,
icon: markerIcon
});
var infowindow = new google.maps.InfoWindow({
content: ContentString
});
marker.addListener('click', function () {
closeLastOpenedInfoWindow();
GetDirecciones(coords, infowindow, marker)
infowindow.open(map, marker);
lastOpenedInfoWindow = infowindow;
});
marker.Nombre = nomEquipo
markers.push(marker);
if (markers.length > 1 && coordspoly.length < 1) {
fitBoundsToVisibleMarkers()
} else if (markers.length === 1 && coordspoly.length < 1) {
map.setZoom(15);
map.setCenter(coords);
}
}
function DeleteMarkers() {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
markers = [];
for (var i = 0; i < polylines.length; i++) {
polylines[i].setMap(null);
}
polylines = [];
coordspoly = [];
}
var timeout = 1500;
function GetDireccionesGV(posicion, indice, multiplicador) {
setTimeout(function () {
var columnaSeleccionada = 2 + indice;
var tr = $("#C_GvBarra").DataTable().row(indice).node();
var lat = posicion.lat;
var lng = posicion.lng;
var largo;
var url = '<%= ClsPaginas.UrlDirecciones%>' + 'nominatim/reverse.php?format=jsonv2&lat=' + lat + '&lon=' + lng;
if ($("#HdnOpcion").val() === 'All' || $("#HdnOpcion").val() === 'TPS') { largo = 37 } else { largo = 74 }
if ($())
$.getJSON(url, function (data) {
if (typeof (data.error) === 'undefined') {
if (multiplicador > 0) {
if (typeof (markers[indice]) !== 'undefined') {
markers[indice].formatted_addressrow = data.display_name
}
}
if (data.display_name.length > largo) {
tr.cells[2].innerHTML = data.display_name.substring(0, largo) + '...';
} else {
tr.cells[2].innerHTML = data.display_name;
}
tr.cells[2].title = data.display_name;
$("#C_GvBarra_HdnDireccionRow_" + indice).val(data.display_name);
} else {
tr.cells[2].innerHTML = "No se encontró la dirección";
$("#C_GvBarra_HdnDireccionRow_" + indice).val("No se encontró la dirección;");
}
});
}, timeout + (indice));
}
var countdown = 1;
var countup = 1;
var pixels = 0;
function GetDireccionesGVClick(posicion, indice) {
if (typeof (markers[indice].formatted_addressrow) === 'undefined') {
setTimeout(function () {
var columnaSeleccionada = 2 + indice;
var tr = $("#C_GvBarra").DataTable().row(indice).node()
geocoder.geocode({ 'location': posicion }, function (results, status) {
if (status === 'OK') {
if (results[0]) {
if (typeof (markers[indice]) !== 'undefined') {
markers[indice].formatted_addressrow = results[0].formatted_address
if (typeof (tr) !== 'undefined') {
tr.cells[2].innerHTML = results[0].formatted_address;
}
} else {
console.log("Ocurrio un error al obtener la direccion del punto: " + posicion + "en el indice: " + indice)
}
} else {
markers[indice].formatted_addressrow = "Direccion no encontrada"
tr.cells[2].innerHTML = "Direccion no encontrada;"
}
} else {
markers[indice].formatted_addressrow = "Cargando..."
tr.cells[2].innerHTML = "Cargando..."
}
});
}, timeout);
}
}
function GetDirecciones(posicion, infowindow, marker, indice) {
var lat = posicion.lat
var lng = posicion.lng
var url = '<%= ClsPaginas.UrlDirecciones%>' + 'nominatim/reverse.php?format=jsonv2&lat=' + lat + '&lon=' + lng;
$.getJSON(url, function (data) {
if (typeof (data.error) === 'undefined') {
marker.formatted_address = data.display_name;
var contenido = infowindow.getContent();
if (contenido.indexOf("direccion") >= 0) {
var html = $($.parseHTML(contenido));
var dir = html.filter(".direccion");;
dir.text("Dirección: " + data.display_name);
var htmlstring = "";
for (var i = 0; i < html.length; i++) {
htmlstring = htmlstring.concat(html[i].outerHTML);
}
infowindow.setContent(htmlstring);
} else {
infowindow.setContent(contenido + "<div class='direccion' style='margin-left:5px'>" + "Dirección: " + data.display_name + "</div>");
}
if (indice > -1) {
if (data.display_name.length > 74) {
if (typeof (tr) !== 'undefined') {
tr.cells[2].innerHTML = data.display_name.substring(0, 74) + '...'
}
} else {
if (typeof (tr) !== 'undefined') {
tr.cells[2].innerHTML = data.display_name
}
}
}
} else {
marker.formatted_address = "Dirección no encontrada";
if (contenido.indexOf("direccion") >= 0) {
var html = $($.parseHTML(contenido));
var dir = html.filter(".direccion");;
dir.text("Dirección no encontrada");
var htmlstring = "";
for (var i = 0; i < html.length; i++) {
htmlstring = htmlstring.concat(html[i].outerHTML);
}
infowindow.setContent(htmlstring);
} else {
infowindow.setContent(infowindow.getContent() + "<div style='margin-left:5px'> Dirección: No Encontrada </div>");
}
if (indice) {
var col = indice + 1
var tr = $('#C_GvBarra tr').filter(':nth-child(' + col + ')')
tr.find("td").filter(':nth-child(3)').html(results[0].formatted_address);
}
}
});
}
</script>
</asp:Content>