$("#baraLimba").hide(); $(window).on('load', function(){ setTimeout(removeLoader, 2000); }); function removeLoader(){ $( '#loadingDiv' ).fadeOut(500, function() { $( '#loadingDiv' ).remove(); }); } var graficRezultate = function(chartData, chartOptions) { var ctx = document.getElementById('myChart'); var myChart = new Chart(ctx, { type: 'bar', data: chartData, options: chartOptions }); }; var graficRezultateS = function(labels, values) { var ctx = document.getElementById('myChart'); var color = Chart.helpers.color; var myChart = new Chart(ctx, { type: 'line', data: { labels: labels, datasets: [{ label: 'Temperatură', backgroundColor: color(window.chartColors.blue).alpha(0.5).rgbString(), borderColor: window.chartColors.blue, borderWidth: 1, pointRadius: 0, fill: 'start', data: values }] }, options: { animation: false, responsive: true, legend: { labels: { boxWidth: 10 } }, tooltips: { mode: 'index', intersect: false, callbacks: { label: function(tooltipItems, data) { var label = data.datasets[tooltipItems.datasetIndex].label; return label + ': ' + tooltipItems.yLabel + ' °C'; } } }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ ticks: { autoSkip: true } }], yAxes: [{ ticks: { beginAtZero: true } }] } } }); }; function titleCase(str) { str = str.toLowerCase().split(' '); for (var i = 0; i < str.length; i++) { str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1); } return str.join(' '); } $(function(){ $('#slider').slider({ max: 1, min: 0, value: 1, step: 0.1 }); }); var neighbors; var getsections = {}; var geojson; window.onload = function () { var neighbors function styleSectii(feature) { return { fillColor: getColor(feature.properties.prezenta), weight: 1, opacity: 0, color: '#000000', dashArray: '0.5', fillOpacity: 0.6 }; } function styleContur(feature) { return { fillColor: '#ffffff', opacity: 1, weight: 1, color: '#000000', dashArray: '0.5', fillOpacity: 0 }; } var optiuniSectiiPunct = { radius: 2, fillColor: '#000000', color: '#000000', weight: 1, opacity: 1, fillOpacity: 1, pane: 'sectii_punct' }; function styleFiecareVot(castigator) { return { radius: 1, fillColor: getColor(castigator), color: getColor(castigator), fillOpacity: 1, fill: true } } function getColor(d) { return d == 'munte' ? '#40407a' : d == 'litoral' ? '#2980b9': d == 'rural' ? '#f39c12': '#ff5252'; } var req = new XMLHttpRequest(); var url = 'data/uat_simplificat.topojson'; req.open('GET', url, true); req.onreadystatechange = handler; req.send(); topoob = {}; getsections = {}; responseText = req.responseText function parseTopoJSON(layer, style, onEachF, pane) { topoob = JSON.parse(req.responseText) neighbors = topojson.neighbors(topoob.objects[layer].geometries); getsections = topojson.feature(topoob, topoob.objects[layer]) getsections.features = getsections.features.map(function(fm,i){ var ret = fm; ret.indie = i; return ret }); content = L.geoJson(getsections, {style: style, onEachFeature: onEachF, pane: pane}); return content; } function handler(){ if(req.readyState === XMLHttpRequest.DONE){ function hideShowLayers (layer) { var layers = ['locations_data']; var layersLength = layers.length; for (var i = 0; i < layersLength; i++) { if (layers[i] == layer){ map.addLayer(eval(layers[i])); } else{ map.removeLayer(eval(layers[i])); } } } var layer = 'terrain'; map = new L.Map('mapcon', { center: new L.LatLng(46, 26), zoom: 7, scrollWheelZoom: false }); map.options.minZoom = 7; map.createPane('locations_data'); map.createPane('uat'); var lightOSM = L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', { maxZoom: 18, zIndex: 1, attribution: '© Powered by Copernicus' }); var normalOSM = L.tileLayer( 'https://api.maptiler.com/maps/topo/{z}/{x}/{y}.png?key=X8ytgIaSzVnjEGBDIuss', { attribution: '© Powered by Copernicus', subdomains: ['a','b','c'], opacity: 0.5 }); var satellite = L.tileLayer( 'https://api.maptiler.com/maps/hybrid/{z}/{x}/{y}.jpg?key=X8ytgIaSzVnjEGBDIuss', { attribution: '© Powered by Copernicus', subdomains: ['a','b','c'] }); var OpenTopoMap = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', { maxZoom: 17, attribution: 'Map data: © OpenStreetMap contributors, SRTM | Map style: © OpenTopoMap (CC-BY-SA)' }); var satMutant = L.gridLayer.googleMutant({ maxZoom: 24, type:'satellite' }); var blankBasemap = L.tileLayer(''); map.addLayer(lightOSM, OpenTopoMap, satMutant); //Încărcare straturi din TopoJSON //locations_data = parseTopoJSON('locatii_asezari', styleSectii, onEachFeature, 'locations_data'); locations_data = parseTopoJSON('uat_simplificat', styleSectii, onEachF, 'uat'); loc_search = $.getJSON('data/centroizi_uat.geojson', function (data) { fuse = new Fuse(loc_search.responseJSON.features, { keys: [ 'properties.uat' ] }); }); var greenIcon = new L.icon({ iconUrl: 'images/icon_casa3.png', iconSize: [31, 30], // size of the icon iconAnchor: [15, 15], // point of the icon which will correspond to marker's location popupAnchor: [15, 15] // point from which the popup should open relative to the iconAnchor }); locatii_asezari = $.getJSON("data/locatii_asezari.geojson",function(data){ L.geoJson(data, { onEachFeature: onEachFeature, pane: 'locations_data', pointToLayer: function(feature,latlng){ var marker = L.marker(latlng, {icon: greenIcon}); return marker; } }).addTo(map); }); map.getPane('locations_data').style.zIndex = 1200; map.getPane('uat').style.zIndex = 1; //map.addLayer(locations_data); var searchControl = new L.Control.Search({ layer: locations_data, propertyName: 'uat', marker: false, filterData: function(text, records) { var jsons = fuse.search(text), ret = {}, key; for(var i in jsons) { key = jsons[i].properties.uat; ret[ key ]= records[key]; } return ret; }, moveToLocation: function(latlng, title, map) { var zoom = map.getBoundsZoom(latlng.layer.getBounds()); map.setView(latlng, zoom); } }); searchControl.on('search:locationfound', function(e) { e.layer.setStyle({fillColor: '#3f0', color: '#0f0'}); if(e.layer._popup) e.layer.openPopup(); }).on('search:collapsed', function(e) { featuresLayer.eachLayer(function(layer) { featuresLayer.resetStyle(layer); }); }); map.addControl(searchControl); function highlightFeature(e){ var layer = e.target; info.update(layer.feature.properties, e.target.options.pane); } function resetHighlight(e){ if (e.target.options.pane == 'locations_data') locations_data.resetStyle(e.target); //info.update(e.target.properties, e.target.options.pane); //$('#myChart').css('display', 'none'); //$('#rezultate_info').css('display', 'none'); } function zoomToFeature(e) { map.fitBounds(e.target.getBounds()); } function onEachFeature(feature, layer){ layer.on({ mouseover: highlightFeature, mouseout: resetHighlight, click: highlightFeature}) } function onEachF(feature, layer){ layer.on({ }) } var info = L.control(); info.onAdd = function(map) { this._div = L.DomUtil.create('div', 'info'); this.update(); return this._div; } info.update = function(props, strat){ if (props){ this._div.innerHTML = "
" + "

Informații asezare informală

" + (props ? 'Denumirea populară a zonei: ' + props.toponim + '
' : "") + (props ? 'Localitatea: ' + props.localitate + '
' : "") + (props ? 'UAT: ' + props.uat + '
' : "") + (props ? 'Numărul estimat de locuințe: ' + props.locuitori + '
' : "") + (props ? 'Descriere:
' + props.desc + '
' : "") + (props.foto == 'DA' ? '
' : "") } } info.addTo(map); $('.leaflet-control-attribution').hide(); //var legend = L.control({position: 'bottomleft'}); //legend.onAdd = function (map) { // var div = L.DomUtil.create('div', 'info legend'), // grades = ['munte', 'litoral', 'rural', 'urban'], // labels = ['Munte', 'Litoral', 'Rural', 'Urban']; // for (var i = 0; i < grades.length; i++) { // div.innerHTML += // ' ' + // labels[i] + '
'; // } // return div; //}; //legend.addTo(map); $('select').on('changed.bs.select', function(e, clickedIndex, newValue, oldValue) { if (clickedIndex == '0' && newValue == true) map.addLayer(sectii_contur); if (clickedIndex == '0' && newValue == false) map.removeLayer(sectii_contur); if (clickedIndex == '1' && newValue == true) map.addLayer(uat_contur); if (clickedIndex == '1' && newValue == false) map.removeLayer(uat_contur); if (clickedIndex == '2' && newValue == true) map.addLayer(judete_contur); if (clickedIndex == '2' && newValue == false) map.removeLayer(judete_contur); if (clickedIndex == '3' && newValue == true) map.addLayer(sectii_punct); if (clickedIndex == '3' && newValue == false) map.removeLayer(sectii_punct); }); $('#slider').on('slidechange', function( event, ui ) { locations_data.setStyle({fillOpacity: $('#slider').slider('value')}); if ($('#rezultat').val() == '5'){ map.removeLayer(fiecare_procent_sectie); map.addLayer(fiecare_procent_sectie); } if ($('#rezultat').val() == '6'){ map.removeLayer(fiecare_procent_uat); map.addLayer(fiecare_procent_uat); } if ($('#rezultat').val() == '7'){ map.removeLayer(fiecare_procent_judete); map.addLayer(fiecare_procent_judete); } }); var draggableMarker; function putDraggable() { /* create a draggable marker in the center of the map */ draggableMarker = L.marker([ map.getCenter().lat, map.getCenter().lng], {draggable:true, zIndexOffset:900}).addTo(map); /* collect Lat,Lng values */ draggableMarker.on('dragend', function(e) { $("#latitudine-asezare").val(this.getLatLng().lat); $("#longitudine-asezare").val(this.getLatLng().lng); }); } $("#get-coordonate").click(function() { putDraggable(); }); $("#afisare-chestionar").click(function() { map.removeLayer(draggableMarker) }); $('#fundal').change(function () { if ($('#fundal').val() == '1'){ map.addLayer(lightOSM); map.removeLayer(OpenTopoMap); map.removeLayer(satMutant); } if ($('#fundal').val() == '2'){ map.addLayer(OpenTopoMap); map.removeLayer(lightOSM); map.removeLayer(satMutant); } if ($('#fundal').val() == '3'){ map.addLayer(satMutant); map.removeLayer(lightOSM); map.removeLayer(OpenTopoMap); } }); $('#rezultate_uat_info').css('display', 'none'); } } }