var map; var markers = new Array(); var markers2 = new Array(); var latlng; var viaje1; $().ready(function () { $(".btnReservar").button(); $(".btnReservar").click(fnReservar); // TOOLTIPS DIVISAS $('.divisaTooltip').tooltip(); // PESTAÑERO CODA-SLIDER var panelSeleccionado = 5; if ($('.tituloTab1').text() != '') { //viaje1.TituloPestana1 != '') { if (panelSeleccionado == 5) { panelSeleccionado = 1; } } if ($('.tituloTab2').text() != '') { //viaje1.TituloPestana2 != '') { if (panelSeleccionado == 5) { panelSeleccionado = 2; } } if ($('.tituloTab3').text() != '') { //viaje1.TituloPestana3 != '') { if (panelSeleccionado == 5) { panelSeleccionado = 3; } } if ($('.tituloTab4').text() != '') { //viaje1.TituloPestana4 != '') { if (panelSeleccionado == 5) { panelSeleccionado = 4; } } $('#coda-slider-5').codaSlider({ dynamicArrows: false, dynamicTabs: false, firstPanelToLoad: panelSeleccionado }); // MAPA var styles = [ { stylers: [ { hue: "#00ffe6" }, { saturation: -20 } ] }, { featureType: "road", elementType: "geometry", stylers: [ { lightness: 100 }, { visibility: "simplified" } ] }, { featureType: "water", stylers: [{ color: "#5B4947"}] }, { featureType: "road", elementType: "labels", stylers: [{ visibility: "off"}] } ]; latlng = new google.maps.LatLng(65, -19); var myOptions = { backgroundColor: '#5B4947', zoom: 5, center: latlng, mapTypeId: google.maps.MapTypeId.TERRAIN, mapTypeControl: false, streetViewControl: false, zoomControl: false, panControl: false, scaleControl: false, scaleControlOptions: { position: google.maps.ControlPosition.LEFT_BOTTOM } }; map = new google.maps.Map(document.getElementById("divContenedorMapa"), myOptions); map.setOptions({ styles: styles }); // Botón Ampliar Mapa var ampliarMapaDiv = BotonAmpliarMapa(); ampliarMapaDiv.index = 1; map.controls[google.maps.ControlPosition.TOP_RIGHT].push(ampliarMapaDiv); google.maps.event.addDomListener(ampliarMapaDiv, 'click', function () { fnMostrarMapaAmpliado() }); $('.thumbnails img').click(fnMostrarImagen); codViaje = $('.hdnCodViaje').val(); fnMostrarViaje(codViaje); }); function fnMostrarImagen() { var newImage = ''; $('.galeria').append(newImage); var comentario = $(this).attr('comment'); $('.letrero').animate({ height: '1px' }, 500, function () { $('#h3letrero').html(comentario); if (comentario != '') { $('.letrero').animate({ height: '26px' }, 500); } }); //$('.galeria img').attr('src', '/handlers/ObtenerImagen.ashx?id=' + $(this).attr('codimagen')); //$('.galeria img').hide(); } function fadeIn(element) { $(element).fadeIn(1000); } function fnMostrarMapaAmpliado() { //$("#map_canvas2:ui-dialog").dialog("destroy"); //$("#map_canvas2").dialog("destroy"); $("#map_canvas2").dialog({ height: 600, width: 800, position: ['center', 100], modal: true, draggable: true, resizable: false, show: "fade", hide: "fade" }); var myOptions2 = { zoom: 6, center: latlng, mapTypeId: google.maps.MapTypeId.HYBRID, streetViewControl: false, scaleControl: true, scaleControlOptions: { position: google.maps.ControlPosition.LEFT_BOTTOM } }; map2 = new google.maps.Map(document.getElementById("map_canvas2"), myOptions2); for (var i = 0; i < viaje1.Localizaciones.length; i++) { var marker = añadirMarker2(viaje1.Localizaciones[i], i); markers2[i] = marker; } var rendererOptions = { suppressMarkers: true }; var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions); directionsDisplay.setMap(map2); var polyline = new google.maps.Polyline(); polyline.setMap(map2); var origen; var destino; var puntosIntermedios = new Array(); var routes = new Array(); for (i = 0, j = markers.length; i < j; ++i) { if (!origen) { origen = markers[i].getPosition(); routes.push(markers[i].getPosition()); } else if (i == (j - 1)) { destino = markers[i].getPosition(); routes.push(markers[i].getPosition()); } else { var puntoIntermedio = { location: markers[i].getPosition() } puntosIntermedios.push(puntoIntermedio); routes.push(markers[i].getPosition()); } } if (origen && destino) { var destinoReal = destino; if (viaje1.EsCircuito) { var puntoIntermedio = { location: destino } puntosIntermedios.push(puntoIntermedio); destinoReal = origen; routes.push(origen); } var directionsService = new google.maps.DirectionsService(); var travelMode = google.maps.DirectionsTravelMode.DRIVING; switch (viaje1.TravelMode) { case 1: travelMode = google.maps.DirectionsTravelMode.DRIVING; break; case 2: travelMode = google.maps.DirectionsTravelMode.WALKING; break; case 3: travelMode = google.maps.DirectionsTravelMode.BICYCLING; break; } var request = { origin: origen, destination: destinoReal, waypoints: puntosIntermedios, travelMode: travelMode }; directionsService.route(request, function (response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setOptions({ polylineOptions: { strokeColor: '#3B2927', strokeWeight: 5, strokeOpacity: 0.7 }, preserveViewport: true }); directionsDisplay.setDirections(response); } else { polyline = new google.maps.Polyline({ path: routes , map: map2 , strokeColor: '#0000ff' , strokeWeight: 5 , strokeOpacity: 0.6 , clickable: false }); var n = -400; var s = 400; var e = -400; var w = 400; for (var r = 0; r < routes.length; r++) { if (routes[r].lat() > n) { n = routes[r].lat(); } if (routes[r].lat() < s) { s = routes[r].lat(); } if (routes[r].lng() > e) { e = routes[r].lng(); } if (routes[r].lng() < w) { w = routes[r].lng(); } } var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(s, w), new google.maps.LatLng(n, e)); map2.fitBounds(bounds); } }); } else { map2.setCenter(latlng); } } function BotonAmpliarMapa() { var controlDiv = document.createElement('DIV'); controlDiv.style.padding = '5px'; var controlUI = document.createElement('DIV'); controlUI.style.backgroundColor = '#5B4947'; controlUI.style.borderStyle = 'solid'; controlUI.style.borderColor = '#666666'; controlUI.style.borderWidth = '1px'; controlUI.style.cursor = 'pointer'; controlUI.style.textAlign = 'center'; controlUI.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=135,strength=2)'; controlUI.style.fontWeight = 'bold'; controlUI.style.color = '#FFF'; controlUI.style.boxShadow = '2px 2px 2px 0px rgb(120,120,120)'; controlUI.title = 'Visión ampliada del mapa'; controlDiv.appendChild(controlUI); // Set CSS for the control interior var controlText = document.createElement('DIV'); controlText.style.fontFamily = 'Arial,sans-serif'; controlText.style.fontSize = '12px'; controlText.style.fontWeight = 'bold'; controlText.style.paddingLeft = '4px'; controlText.style.paddingRight = '4px'; controlText.style.paddingTop = '2px'; controlText.style.paddingBottom = '2px'; controlText.innerHTML = 'Ampliar'; controlUI.appendChild(controlText); return controlDiv; } function fnMostrarViaje(codViaje) { $.ajax( { url: "/FichaViaje.aspx/ObtenerViaje1", type: "POST", data: "{'codViaje1':'" + codViaje + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var viajes1 = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; viaje1 = viajes1[0]; if (viaje1) { //LOCALIZACIONES for (var i = 0; i < viaje1.Localizaciones.length; i++) { var marker = añadirMarker(viaje1.Localizaciones[i], i); markers[i] = marker; } var rendererOptions = { suppressMarkers: true }; var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions); directionsDisplay.setMap(map); var polyline = new google.maps.Polyline(); polyline.setMap(map); var origen; var destino; var puntosIntermedios = new Array(); var routes = new Array(); for (i = 0, j = markers.length; i < j; ++i) { if (!origen) { origen = markers[i].getPosition(); routes.push(markers[i].getPosition()); } else if (i == (j - 1)) { destino = markers[i].getPosition(); routes.push(markers[i].getPosition()); } else { var puntoIntermedio = { location: markers[i].getPosition() } puntosIntermedios.push(puntoIntermedio); routes.push(markers[i].getPosition()); } } if (origen && destino) { var destinoReal = destino; if (viaje1.EsCircuito) { var puntoIntermedio = { location: destino } puntosIntermedios.push(puntoIntermedio); destinoReal = origen; routes.push(origen); } var directionsService = new google.maps.DirectionsService(); var travelMode = google.maps.DirectionsTravelMode.DRIVING; switch (viaje1.TravelMode) { case 1: travelMode = google.maps.DirectionsTravelMode.DRIVING; break; case 2: travelMode = google.maps.DirectionsTravelMode.WALKING; break; case 3: travelMode = google.maps.DirectionsTravelMode.BICYCLING; break; } var request = { origin: origen, destination: destinoReal, waypoints: puntosIntermedios, travelMode: travelMode }; directionsService.route(request, function (response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setOptions({ polylineOptions: { strokeColor: '#3B2927', strokeWeight: 5, strokeOpacity: 0.7 }, preserveViewport: true }); directionsDisplay.setDirections(response); } else { polyline = new google.maps.Polyline({ path: routes , map: map , strokeColor: '#4B3937' , strokeWeight: 5 , strokeOpacity: 0.6 , clickable: false }); var n = -400; var s = 400; var e = -400; var w = 400; debugger; for (var r = 0; r < routes.length; r++) { if (routes[r].lat() > n) { n = routes[r].lat(); } if (routes[r].lat() < s) { s = routes[r].lat(); } if (routes[r].lng() > e) { e = routes[r].lng(); } if (routes[r].lng() < w) { w = routes[r].lng(); } } } }); } } }, error : function() { alert("Error");} }) }; function añadirMarker(localizacion, indice) { var location = new google.maps.LatLng(localizacion.Latitud, localizacion.Longitud); var imagen = '/images/markers/number_' + (indice + 1).toString() + '.png'; var marker = new google.maps.Marker({ position: location, title: localizacion.Titulo, html: '
' + localizacion.Titulo + '
' + localizacion.Descripcion + '
' + localizacion.Titulo + '
' + localizacion.Descripcion + '