Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- var map = (function() {
- var svgPanZoon;
- var maxHeight = 950;
- var currentHeight = $(window).height() - 40;
- var onReady = function(callback) {
- var intervalID = window.setInterval(checkReady, 1000);
- function checkReady() {
- if (document.getElementsByTagName('body')[0] !== undefined) {
- window.clearInterval(intervalID);
- callback.call(this);
- }
- }
- };
- var show = function(id, value) {
- if (value) {
- $('#' + id).removeClass('hidden')
- } else {
- $('#' + id).addClass('hidden')
- }
- };
- var capitalizeText = function(str) {
- return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
- };
- return {
- init: function() {
- onReady(function() {
- show('page', true);
- $('#wrapper-map').css({
- height: currentHeight > maxHeight ? maxHeight : currentHeight
- });
- $('#list-layers').css({
- height: $('#wrapper-map').height()
- });
- $('#layers').jstree({
- 'plugins': ["wholerow", "checkbox", "types"],
- 'checkbox': {
- 'three_state': false,
- 'whole_node': false,
- 'tie_selection': false
- },
- 'core': {
- "themes": {
- "responsive": false
- },
- 'data': [
- {
- "id": 'RED_VIAL_VECINAL',
- "text": "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Red Vial Vecinal</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-minus red-vial-vecinal",
- "state": {
- "checked": false
- }
- },
- {
- "id": 'RED_VIAL_NACIONAL',
- "text": "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Red Vial Nacional</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-minus red-vial-nacional",
- "state": {
- "checked": false
- }
- }, {
- "id": 'RED_VIAL_DEPARTAMENTAL',
- "text": "Red Vial Departamental",
- "icon": "fa fa-minus red-vial-departamental",
- "state": {
- "checked": false
- }
- },
- {
- "id": 'FERROCARRIL',
- "text": "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Ferrocarril</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-minus ferrocarril",
- "state": {
- "checked": false
- }
- }, {
- "id": 'HIDROGRAFIA',
- "text": "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Hidrografía</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-minus hidrografia",
- "state": {
- "checked": false
- }
- }, {
- "id": 'LAGUNAS',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Lagunas</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square lagunas",
- "state": {
- "checked": false
- }
- }, {
- "id": 'LIMITE_SUBCUENCA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Límite Subcuenca</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square-o",
- "state": {
- "checked": true
- }
- }, {
- "id": 'CURVAS_NIVEL',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Curvas de Nivel</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-minus curva-nivel",
- "state": {
- "checked": false
- }
- }, {
- "id": 'CENTROS_POBLADOS',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Centros Poblados</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-circle",
- "state": {
- "checked": false
- }
- }, {
- "id": 'CAPITAL_DEPARTAMENTAL',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Capital Departamental</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-circle",
- "state": {
- "checked": false
- }
- }, {
- "id": 'CAPITAL_PROVINCIAL',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Capital Provincial</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-circle",
- "state": {
- "checked": false
- }
- }, {
- "id": 'CAPITAL_DISTRITAL',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Capital Distrital</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-circle",
- "state": {
- "checked": false
- }
- },
- {
- "id": 'AREA_CONSERVACION',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Área de conservación</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square area-conservacion",
- "state": {
- "checked": false
- }
- }, {
- "id": 'CAPACIDAD_USO_MAYOR',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Capacidad de Uso Mayor</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square capacidad-uso-mayor",
- "state": {
- "checked": true
- }
- }, {
- "id": 'COBERTURA_VEGETAL',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Cobertura Vegetal</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square cobertura-vegetal",
- "state": {
- "checked": false
- }
- }, {
- "id": 'COMUNIDADES_CAMPESINAS',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Comunidades Campesinas</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square comunidades-campesinas",
- "state": {
- "checked": false
- }
- }, {
- "id": 'CONFLICTOS_TIERRAS',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Conflictos de Tierras</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square conflictos-tierras",
- "state": {
- "checked": false
- }
- }, {
- "id": 'GEOLOGIA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Geología</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square geologia",
- "state": {
- "checked": false
- }
- }, {
- "id": 'FISIOGRAFIA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Fisiografía</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square fisiografia",
- "state": {
- "checked": false
- }
- }, {
- "id": 'GEOMORFOLOGIA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Geomorfología</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square geomorfologia",
- "state": {
- "checked": false
- }
- }, {
- "id": 'HIDROGEOLOGIA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Hidrogeología</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square hidrografia",
- "state": {
- "checked": false
- }
- }, {
- "id": 'REGIONES_NATURALES',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Regiones Naturales</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square regiones-naturales",
- "state": {
- "checked": false
- }
- }, {
- "id": 'PRECIPITACION_MEDIA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Precipitación Media</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square precipitacion-media",
- "state": {
- "checked": false
- }
- }, {
- "id": 'TEMPERATURA_MEDIA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Temperatura Media</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square temperatura-media",
- "state": {
- "checked": false
- }
- }, {
- "id": 'USO_ACTUAL_TIERRAS',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Uso Actual de Tierras</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square uso-actual-tierras",
- "state": {
- "checked": false
- }
- }, {
- "id": 'ZONAS_VIDA',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Zonas de Vida</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square zonas-vida",
- "state": {
- "checked": false
- }
- }, {
- "id": 'LIMITE_DISTRITAL',
- 'text': "<div style='display: inline-block; width: 85%;'><span style='width: 50%; display: inline-block;'>Límite Distrital</span> <span style='text-align: right; width: 50%; display: none;'><i class='fa fa-adjust' onclick='showOpacity()';></i> <i class='fa fa-search'></i></span></div>",
- "icon": "fa fa-square limite-distrital",
- "state": {
- "checked": true
- }
- },
- ]
- },
- }).on("check_node.jstree uncheck_node.jstree", function(e, data) {
- $('#layer-description').addClass('hidden');
- $( "#informacion-laguna").addClass('hidden');
- $( "#informacion-poblados" ).addClass('hidden');
- $( "#informacion-conservacion" ).addClass('hidden');
- $( "#informacion-vegetal" ).addClass('hidden');
- $( "#informacion-comunidades" ).addClass('hidden');
- $( "#informacion-conflictos" ).addClass('hidden');
- $( "#informacion-geologias" ).addClass('hidden');
- $( "#informacion-fisiografias" ).addClass('hidden');
- $( "#informacion-geomorfologias" ).addClass('hidden');
- $( "#informacion-hidrogeologias" ).addClass('hidden');
- $( "#informacion-naturales" ).addClass('hidden');
- $( "#informacion-precipitaciones" ).addClass('hidden');
- $( "#informacion-temperatura" ).addClass('hidden');
- $( "#informacion-tierras" ).addClass('hidden' );
- $( "#informacion-centros-poblados").addClass('hidden');
- var layerName = data.node.id
- if (data.node.state.checked) {
- $('#' + layerName).removeClass('hidden');
- $('#' + layerName + '_-_Default').removeClass('hidden');
- } else {
- $('#' + layerName).addClass('hidden');
- $('#' + layerName + '_-_Default').addClass('hidden');
- }
- });
- svgPanZoom = svgPanZoom('#svg', {
- zoomEnabled: true,
- controlIconsEnabled: false,
- fit: true,
- center: true,
- contain: false,
- dblClickZoomEnabled: false,
- // maxZoom: 2,
- minZoom: 1.5,
- beforePan: function(oldPan, newPan) {
- var stopHorizontal = true,
- stopVertical = true,
- gutterWidth = $("#svg").width(),
- gutterHeight = $("#svg").height()
- // Computed variables
- ,
- sizes = this.getSizes(),
- leftLimit = -((sizes.viewBox.x + sizes.viewBox.width) * sizes.realZoom) + gutterWidth,
- rightLimit = sizes.width - gutterWidth - (sizes.viewBox.x * sizes.realZoom),
- topLimit = -((sizes.viewBox.y + sizes.viewBox.height) * sizes.realZoom) + gutterHeight,
- bottomLimit = sizes.height - gutterHeight - (sizes.viewBox.y * sizes.realZoom)
- customPan = {}
- customPan.x = Math.max(leftLimit, Math.min(rightLimit, newPan.x))
- customPan.y = Math.max(topLimit, Math.min(bottomLimit, newPan.y))
- return customPan
- }
- });
- svgPanZoom.zoom(1.5);
- svgPanZoom.panBy({x: 0, y: -180});
- // $('#LAGUNAS path').click(function(event) {
- // var lagunaId = $(this).attr('data-id');
- // $.getJSON( 'data/LAGUNAS.json', function(data) {
- // var len = data['FID'].length;
- // var indexResult = 0;
- // for (var index = 0; index < len; index++) {
- // if (lagunaId === data['FID'][index]) {
- // indexResult = index;
- // break;
- // }
- // }
- // $('.table tbody').empty();
- // var rowData = '';
- // for (var key in data) {
- // rowData += '<td class="bold" style="width:15%; border-right: 1px solid #e7ecf1 !important;">' + capitalizeText(key) + '</td>';
- // rowData += '<td style="width:50%">' + data[key][indexResult] + '</td>';
- // $('.table tbody').append('<tr>' + rowData + '</tr>');
- // rowData = '';
- // }
- // $('#layer-description').removeClass('hidden');
- // });
- // });
- // $('#LAGUNAS_-_Default g').click(function(event) {
- // var lagunaId = $(this).attr('data-id');
- // $.getJSON( 'data/LAGUNAS.json', function(data) {
- // var len = data['FID'].length;
- // var indexResult = 0;
- // for (var index = 0; index < len; index++) {
- // if (lagunaId === data['FID'][index]) {
- // indexResult = index;
- // break;
- // }
- // }
- // $('.table tbody').empty();
- // var rowData = '';
- // for (var key in data) {
- // rowData += '<td class="bold" style="width:15%; border-right: 1px solid #e7ecf1 !important;">' + capitalizeText(key) + '</td>';
- // rowData += '<td style="width:50%">' + data[key][indexResult] + '</td>';
- // $('.table tbody').append('<tr>' + rowData + '</tr>');
- // rowData = '';
- // }
- // $('#layer-description').removeClass('hidden');
- // });
- // });
- // $('path').click(function(event) {
- // try {
- // var parentId = $(this).closest('.polygon').attr('id');
- // var title = $("#" + parentId).attr("data-title")
- // var fillColor = $(this).attr('fill').toUpperCase();
- // if (parentId == 'CAPACIDAD_USO_MAYOR' ||
- // parentId == 'CENTROS_POBLADOS' ||
- // parentId == 'COBERTURA_VEGETAL' ||
- // parentId == 'COMUNIDADES_CAMPESINAS' ||
- // parentId == 'CONFLICTOS_TIERRAS' ||
- // parentId == 'FISIOGRAFIA' ||
- // parentId == 'GEOLOGIA' ||
- // parentId == 'GEOMORFOLOGIA' ||
- // parentId == 'HIDROGEOLOGIA' ||
- // parentId == 'LAGUNAS' ||
- // parentId == 'PRECIPITACION_MEDIA' ||
- // parentId == 'REGIONES_NATURALES' ||
- // parentId == 'TAXONOMIA_SUELOS' ||
- // parentId == 'TEMPERATURA_MEDIA' ||
- // parentId == 'USO_ACTUAL_TIERRAS' ||
- // parentId == 'ZONAS_VIDA') {
- // var indexResult = 0;
- // $.getJSON( 'data/' + parentId + '.json', function( data ) {
- // var len = data['COLOR'].length;
- // for (var index = 0; index < len; index++) {
- // if (fillColor === data['COLOR'][index]) {
- // indexResult = index;
- // break;
- // }
- // }
- // $('.table tbody').empty();
- // var rowData = '';
- // for (var key in data) {
- // rowData += '<td class="bold" style="width:15%; border-right: 1px solid #e7ecf1 !important;">' + capitalizeText(key) + '</td>';
- // if (key === 'COLOR') {
- // rowData += '<td style="width:50%"><div class="table-color" style="background: ' + data[key][indexResult] + ';"></div></td>';
- // } else {
- // rowData += '<td style="width:50%">' + data[key][indexResult] + '</td>';
- // }
- // $('.table tbody').append('<tr>' + rowData + '</tr>');
- // rowData = '';
- // }
- // $('#layer-description').removeClass('hidden');
- // });
- // }
- // } catch(e) {
- // console.log(e);
- // }
- // });
- show('loading', false);
- $('#init-message').modal('show');
- });
- },
- };
- })();
- window.map = map;
- window.map.init();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement