fix report

parent 492f3714
......@@ -13,7 +13,7 @@ const polygonFeature = wktFormat.readFeature(polygon, {
const light = new ol.layer.Tile({
name: 'mapbox',
source: new ol.source.XYZ({
url:'https://api.tiles.mapbox.com/v4/mapbox.light/{z}/{x}/{y}.png?access_token='+MAPBOX_ACCESS_TOKEN
url: 'https://api.tiles.mapbox.com/v4/mapbox.light/{z}/{x}/{y}.png?access_token=' + MAPBOX_ACCESS_TOKEN
})
});
......@@ -48,7 +48,7 @@ const map = new ol.Map({
view: new ol.View({
center: ol.proj.fromLonLat([-99.19, 19.61]),
zoom: 4,
minZoom:4
minZoom: 4
})
});
......@@ -94,7 +94,7 @@ function changeLayers(especific_layerName) {
name: layerName,
source: new ol.source.XYZ({
projection: 'EPSG:3857',
url: '/reports/tiles/'+purchase_id+'/'+zone+'/'+layerName+'/'+currentDate+'/{z}/{x}/{-y}.png',
url: '/reports/tiles/' + purchase_id + '/' + zone + '/' + layerName + '/' + currentDate + '/{z}/{x}/{-y}.png',
tilePixelRatio: 2
})
});
......@@ -112,7 +112,9 @@ function changeLayers(especific_layerName) {
// remove all if there isn't layername
function removeLayer(layerName) {
if (!layerName) {
layers.forEach(layer => { map.removeLayer(layer); });
layers.forEach(layer => {
map.removeLayer(layer);
});
layers.clear();
return;
}
......@@ -124,7 +126,7 @@ function removeLayer(layerName) {
// set opacity to layers
function setOpacity(value) {
layers.forEach(layer => {
if(layer.get('name') != 'TCI') {
if (layer.get('name') != 'TCI') {
layer.setOpacity(value)
}
})
......@@ -136,16 +138,16 @@ function setOpacity(value) {
//vigila cuando se cierra el menu de comparar y cuando se cierra desactiva la comparacion (si la clase de compare incluye menu-open está abierto)
var compareMenu = document.getElementById('compare');
var observer = new MutationObserver( function(mutations) {
mutations.forEach( function(mutation) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName == 'class') {
if(compareMenu.className.indexOf("open")===-1) { //se cerró el menu de comparacion
if (compareMenu.className.indexOf("open") === -1) { //se cerró el menu de comparacion
exitCompare();
}
}
});
});
observer.observe(compareMenu, { attributes : true, attributeOldValue: true, attributeFilter : ['class'], subtree: true});
observer.observe(compareMenu, {attributes: true, attributeOldValue: true, attributeFilter: ['class'], subtree: true});
//crea el control swipe, que sirve para comparar
var ctrl = new ol.control.Swipe();
......@@ -156,12 +158,12 @@ function compare(labels) {
var swipeControl = false;
map.getControls().forEach(function (control) { //checa si ya se añadio el control de comparacion (swipe), si no lo tiene, lo agrega
if(control instanceof ol.control.Swipe){ //si ya tiene el control agregado
swipeControl =true;
if (control instanceof ol.control.Swipe) { //si ya tiene el control agregado
swipeControl = true;
}
});
if(swipeControl==true) { //si ya tiene el comparador no hace nada, ya esta en modo comparacion
if (swipeControl == true) { //si ya tiene el comparador no hace nada, ya esta en modo comparacion
//map.removeControl(swipeControlObj);
} else { //si no tiene el comparador lo agrega
//removeImageLayers();
......@@ -169,11 +171,14 @@ function compare(labels) {
ctrl.set('position', 0.5);
//console.log(map.controls)
var labelDateLeft = labels[0] //por default compara la primera y ultima fecha
var labelDateRight = labels[labels.length-1]
var labelDateRight = labels[labels.length - 1]
//pone las fechas por default en los selectores de fechas
document.getElementById("selectLeftCompare").value = labelDateLeft;
document.getElementById("selectRightCompare").value = labelDateRight;
//document.getElementById("selectLeftCompare").value = labelDateLeft;
//document.getElementById("selectRightCompare").value = labelDateRight;
//agrega las capas izquierda/derecha
selectLeft(labelDateLeft);
......@@ -183,13 +188,14 @@ function compare(labels) {
document.getElementById("selectLeft").style.display = "block";
document.getElementById("selectRight").style.display = "block";
document.getElementById("timeLine").style.display = "none";
}
}
//sale del modo comparacion
function exitCompare() {
map.getControls().forEach(function (control) { //checa si ya se añadio el control de comparacion (swipe)
if(control instanceof ol.control.Swipe){ //ya tiene el control agregado lo quita
if (control instanceof ol.control.Swipe) { //ya tiene el control agregado lo quita
map.removeControl(control);
}
});
......@@ -197,7 +203,7 @@ function exitCompare() {
//quita las capas de comparacion izquierda/derecha
var imageLayers = map.getLayers().getArray().slice();
imageLayers.forEach(layer => {
if(layer.get('name') === 'left' || layer.get('name') === 'right') {
if (layer.get('name') === 'left' || layer.get('name') === 'right') {
map.removeLayer(layer)
}
})
......@@ -218,7 +224,7 @@ function selectLeft(date) {
opacity: 1,
source: new ol.source.XYZ({
projection: 'EPSG:3857',
url: '/reports/tiles/'+purchase_id+'/'+zone+'/'+layer_type+'/'+labelDateLeft+'/{z}/{x}/{-y}.png',
url: '/reports/tiles/' + purchase_id + '/' + zone + '/' + layer_type + '/' + labelDateLeft + '/{z}/{x}/{-y}.png',
tilePixelRatio: 2,
minZoom: 10,
maxZoom: 15
......@@ -229,7 +235,7 @@ function selectLeft(date) {
}
//selecciona el lado derecho para comparar
function selectRight(date){
function selectRight(date) {
console.log("---------");
console.log(date)
console.log("---------");
......@@ -240,7 +246,7 @@ function selectRight(date){
opacity: 1,
source: new ol.source.XYZ({
projection: 'EPSG:3857',
url: '/reports/tiles/'+purchase_id+'/'+zone+'/'+layer_type+'/'+labelDateRight+'/{z}/{x}/{-y}.png',
url: '/reports/tiles/' + purchase_id + '/' + zone + '/' + layer_type + '/' + labelDateRight + '/{z}/{x}/{-y}.png',
tilePixelRatio: 2,
minZoom: 10,
maxZoom: 15
......@@ -251,21 +257,22 @@ function selectRight(date){
}
//selecciona comparacion vertical u horizontal
function setCompareDirection(direction){
ctrl.set('orientation',direction)
function setCompareDirection(direction) {
ctrl.set('orientation', direction)
//mueve los selectores de fechas
if(direction === 'horizontal'){
if (direction === 'horizontal') {
document.getElementById("selectLeft").style.bottom = "70%";
document.getElementById("selectLeft").style.left = "15%";
document.getElementById("selectRight").style.left = "15%";
}
else{
else {
document.getElementById("selectLeft").style.bottom = "50px";
document.getElementById("selectLeft").style.left = "30%";
document.getElementById("selectRight").style.left = "75%";
}
}
// Fin funciones de comparacion
//******************************
......@@ -295,7 +302,7 @@ function changeMap(selectedMap) {
}
}
function showControlMap(){
function showControlMap() {
if ($('#showControlMap').is(':visible')) {
$("#showControlMap").hide();
$("#hideControlMap").show();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment