//SET VARIABLES var map = null; var minimap = null; var map_tiles = {}; var ctr_tiles = {}; var map_layers = {}; var ctr_layers = {}; var data1 = []; var idPopup = 0; var edifPopup = 0; var checarNome = 0; $(document).ready(function(){ document.getElementById("nomeUsuario").value = ""; $("#searchbar").keypress(function(e){ if(e.keyCode==13) $("#btnSubmit").click(); }); $("#nomeUsuario").keypress(function(e){ if(e.keyCode==13) $("#botaoModal").click(); }); }); function generateRandomHex() { const hexDigits = "0123456789abcdef"; let hexCode = "#"; for (let i = 0; i < 6; i++) { hexCode += hexDigits.charAt(Math.floor(Math.random() * 16)); } return hexCode; } function busca() { p1 = document.getElementById("searchbar").value; $.each(data1, function(index, value){ if(map.hasLayer(value)){ map.removeLayer(value); } }); if (isNaN(p1)){ let latLng = p1.split(','); if (latLng[1]) { L.marker([latLng[0], latLng[1]],{icon:marker[20]}).bindPopup("Local pesquisado: "+ p1).addTo(map); map.setView(new L.LatLng(latLng[0], latLng[1]), 14); } else { $.getJSON("https://nominatim.openstreetmap.org/search?q="+ p1 +"&format=geojson&viewbox=-35.829849243164055,-9.723946569800441,-35.591583251953125,-9.467349225571983&bounded=1", function(geoinfo){ $.each(geoinfo.features, function(a){ if(geoinfo.features[a].geometry.type == "Point"){ let coordinates = geoinfo.features[a].geometry.coordinates; L.marker([coordinates[1], coordinates[0]],{icon:marker[20], alt:(JSON.stringify(geoinfo.features[a].properties))}).bindPopup("Local: " + geoinfo.features[a].properties.display_name).addTo(map); map.setView(new L.LatLng(coordinates[1], coordinates[0]), 14); } }); }); } }else{ var http = new XMLHttpRequest(); var url = 'https://semecmaceio.com/v1/integracao/polygon'; var params = '{"lotes":[{"inscricao":'+ Number(p1) +'}]}'; http.open('POST', url, true); //Send the proper header information along with the request http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var data = JSON.parse(http.responseText); L.geoJSON(data.features[0]).bindPopup(data.features[0].properties.LOGRADOURO +" - "+ data.features[0].properties.PATH).addTo(map).openPopup(); } } http.send(params); } } $(document).ready(function(){ //SET TILES map_tiles["osm"] = L.tileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png", { maxNativeZoom:19, maxZoom: 22 }); ctr_tiles["Ruas"] = map_tiles["osm"]; map_tiles["osm2"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { maxNativeZoom:19, maxZoom: 22 }); ctr_tiles["Ruas 2"] = map_tiles["osm2"]; map_tiles["arcgis"] = L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',{ maxNativeZoom:18, maxZoom: 22 }); ctr_tiles["Satelite"] = map_tiles["arcgis"]; /* map_tiles["bing"] = L.tileLayer.bing('AgLA0Q_eJvbHQPhbE1H83YyV3PSBgsatKeO-Otwr8s3DCWsZtxKBsuxEIrXtQjC9',{ maxNativeZoom:18, maxZoom: 20 }); ctr_tiles["Mapa Bing"] = map_tiles["bing"]; */ //SET LAYERS map_layers["search"]= L.layerGroup(); if(typeof my_layer != "undefined" && my_layer == "corona"){ map_layers["Corona Vírus"] = L.layerGroup(); ctr_layers["Corona Vírus"] = map_layers["Corona Vírus"]; map_layers["Mapa de Calor"] = L.layerGroup(); ctr_layers["Mapa de Calor"] = map_layers["Mapa de Calor"]; } camadas_enviadas=[]; if(document.getElementById("postjson").innerText !== ""){ var dadosenviados = JSON.parse(document.getElementById("postjson").innerText); if ("features" in dadosenviados){ map_layers["Dados Enviados"] = L.layerGroup(); ctr_layers["Dados Enviados"] = map_layers["Dados Enviados"]; } else if ("camadas" in dadosenviados){ for ( [key, value] of Object.entries(dadosenviados.camadas)) { map_layers[key] = L.layerGroup(); ctr_layers[key] = map_layers[key]; camadas_enviadas.push(key); } } } map_layers["Bairros"] = L.layerGroup(); ctr_layers["Bairros"] = map_layers["Bairros"]; map_layers["Quadras"] = L.layerGroup(); ctr_layers["Quadras"] = map_layers["Quadras"]; //tipos[90]={"texto":"Quadras", "marker":"1"}; map_layers["Correios"] = L.layerGroup(); ctr_layers["Correios"] = map_layers["Correios"]; map_layers["Vias Oficial"] = L.layerGroup(); ctr_layers["Vias Oficial"] = map_layers["Vias Oficial"]; map_layers["Circunscrição Cartórios"] = L.layerGroup(); ctr_layers["Circunscrição Cartórios"] = map_layers["Circunscrição Cartórios"]; map_layers["Zoneamento Alto-Risco"] = L.layerGroup(); ctr_layers["Zoneamento Alto-Risco"] = map_layers["Zoneamento Alto-Risco"]; map_layers["Zoneamento"] = L.layerGroup(); ctr_layers["Zoneamento"] = map_layers["Zoneamento"]; /* map_layers["Imóveis Municipais"] = L.layerGroup(); ctr_layers["Imóveis Municipais"] = map_layers["Imóveis Municipais"]; map_layers["Lotes Territoriais"] = L.layerGroup(); ctr_layers["Lotes Territoriais"] = map_layers["Lotes Territoriais"]; map_layers["Lei de incentivo do Jaraguá"] = L.layerGroup(); ctr_layers["Lei de incentivo do Jaraguá"] = map_layers["Lei de incentivo do Jaraguá"]; map_layers["Regularidade do Jaraguá"] = L.layerGroup(); ctr_layers["Regularidade do Jaraguá"] = map_layers["Regularidade do Jaraguá"]; map_layers["Evento geológico do Pinheiro"] = L.layerGroup(); ctr_layers["Evento geológico do Pinheiro"] = map_layers["Evento geológico do Pinheiro"]; */ $.getJSON(dir + "json/tipos.php", function(tipos){ $.each(tipos, function(e){ map_layers[e] = L.layerGroup(); ctr_layers[tipos[e]["texto"]] = map_layers[e]; }); //tipos[90]={"texto":"Quadras", "marker":"1"}; teste parece inutil L.control.layers(ctr_tiles, ctr_layers).addTo(map); //STARTER LAYER if(typeof my_layer == "number" && typeof map_layers[my_layer] != "undefined"){ map.addLayer(map_layers[my_layer]); }else if(typeof my_layer != "undefined" && my_layer == "corona"){ map.addLayer(map_layers["Corona Vírus"]); } //SIZE CORRECTION map.invalidateSize(true); }); camadas_qgis=['Cartórios','Geológico','Zoneamento']; for ( key of camadas_qgis) { map_layers["QGIS-"+key] = L.layerGroup(); ctr_layers["QGIS-"+key] = map_layers["QGIS-"+key]; } //SET CONFIG map = L.map('map', { center: [-9.663136558749533, -35.71422457695007], layers: [map_tiles["osm"]], zoomControl: true, maxZoom: 20, minZoom: 12, zoom: 14 }); var plugin = L.control.measure({ position: 'topleft', primaryLengthUnit: 'meters', primaryAreaUnit: 'sqmeters', activeColor: '#363535', completedColor: '#363535', }).addTo(map) minimap = L.map("location-minimap", { center: [0, 0], layers: L.tileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png"), zoomControl: false, zoom: 17 }); //MINIMAP CONTROL minimap._handlers.forEach(function(handler) { handler.disable(); }); //LOAD DATA map.on('overlayadd', function(e){ $.getJSON(dir + "json/tipos.php", function(tipos){ var key = Object.keys(tipos).find(key => tipos[key]["texto"] === e.name); var popupId = 1; var auxiliar = 0; var localStorage = JSON.parse(window.localStorage.getItem('idPontos')); if(key === undefined){ if(map_layers[e.name].getLayers().length === 0){ if(e.name.includes('QGIS')){ $.getJSON("https://geo.maceio.al.gov.br/dados/map.php?" + e.name.replace('QGIS-','').toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, "") + "=1&json=1", function(geoinfo){ $("#info-back").fadeOut("slow"); stopRot(); L.geoJSON(geoinfo, { onEachFeature: function (feature, layer) { if(e.name == "QGIS-Cart"){ layer.bindPopup("Cartório: " + feature.properties.Cartório); cor_random=generateRandomHex(); layer.setStyle({fillColor:cor_random, weight:2, opacity:1, color:'#0F0000', dashArray:'1', fillOpacity:0.1}); } else if(e.name == "Quadras"){ txtset=feature.properties.setor.toString().padStart(2, `0`); txtquad=feature.properties.quadra.toString().padStart(4, `0`); layer.bindPopup("Bairro: " + feature.properties.bairro + "
Setor: " + feature.properties.setor + "
Quadra: " + txtquad + "
Pesquisa Imóveis"); layer.setStyle({fillColor:'blue', weight:1, opacity:1, color:'#23BED6', dashArray:'1', fillOpacity:0.1}).on('click', showLocation); } else { txt_geojson=""; for(const propriedade in feature.properties){ txt_geojson+=`${propriedade}: ${feature.properties[propriedade]}
`; } layer.bindPopup(txt_geojson); cor_random=generateRandomHex(); layer.setStyle({fillColor:cor_random, weight:2, opacity:1, color:'#0F0000', dashArray:'1', fillOpacity:0.1}); } } }).addTo(map_layers[e.name]); }); }else if(camadas_enviadas.length>0 && e.name.includes('Dados')){ for(camada of camadas_enviadas){ if(e.name == camada){ document.getElementById("info-back").style.display = "none"; stopRot(); camadaenviada=dadosenviados.camadas[camada]; var groupMarker = new L.MarkerClusterGroup({ disableClusteringAtZoom: 18, showCoverageOnHover: true, zoomToBoundsOnClick: true, spiderfyOnMaxZoom: true }); $.each(camadaenviada.features, function(a){ if(camadaenviada.features[a].geometry!=null){ if(camadaenviada.features[a].geometry.type=="Point"){ var coordinates = camadaenviada.features[a].geometry.coordinates; }else if(camadaenviada.features[a].geometry.type=="LineString" ){ var coordinates = camadaenviada.features[a].geometry.coordinates[0]; }else if(camadaenviada.features[a].geometry.type=="Polygon" || camadaenviada.features[a].geometry.type=="MultiLineString"){ var coordinates = camadaenviada.features[a].geometry.coordinates[0][0]; }else{ var coordinates = camadaenviada.features[a].geometry.coordinates[0][0][0]; } loc = new L.LatLng(coordinates[1], coordinates[0]); if (!("properties" in camadaenviada.features[a])){ }else if (camadaenviada.features[a].properties.Tipo=="QGIS"){ //L.marker(loc,{icon:marker[20], alt:(JSON.stringify(camadaenviada.features[a].properties))}).bindPopup("Titulo: " + camadaenviada.features[a].properties.Titulo + "
Dados: "+JSON.stringify(camadaenviada.features[a].properties)).addTo(map).openPopup(); } else if (camadaenviada.features[a].properties.KEY===0){ L.marker(loc,{icon:marker[5], alt:(JSON.stringify(camadaenviada.features[a].properties))}).bindPopup("Geo: " + camadaenviada.features[a].properties.GEO_KEY + "
Guia de ITBI: " + camadaenviada.features[a].properties.BUSCA).addTo(map).openPopup(); } else if (camadaenviada.features[a].properties.KEY>0){ L.marker(loc,{icon:marker[6], alt:(JSON.stringify(camadaenviada.features[a].properties))}).bindTooltip("Geo: " + camadaenviada.features[a].properties.GEO_KEY + "
Guia de ITBI: " + camadaenviada.features[a].properties.BUSCA).addTo(groupMarker); } } }); L.geoJSON(camadaenviada,{onEachFeature: function(feature, layer){ poptxt=""; for (const [key, value] of Object.entries(feature.properties)){ poptxt+=`${key}: ${value}
` } layer.bindTooltip(poptxt); var regFillColor = "blue"; var regColor = "blue"; if(("semtitular" in feature.properties && feature.properties.semtitular=="S") || ("territorial" in feature.properties && feature.properties.territorial=="S")){ regColor = "red"; if (feature.properties.territorial=="S"){ regFillColor = "brown"; } } if (feature.properties.semtitular=="S" && feature.properties.territorial=="S"){ regFillColor = "purple"; regColor = "red"; } else if (feature.properties.semtitular=="S" && feature.properties.territorial=="N"){ regFillColor = "yellow"; regColor = "red"; } else if (feature.properties.semtitular=="N" && feature.properties.territorial=="S"){ regFillColor = "brown"; regColor = "red"; } if (feature.properties.maisConstrucao=="S"){ //dash=",stroke-dasharray='16'"; dash="6 20"; } else { //dash=",stroke-dasharray='0'"; dash="0"; } //layer.bindPopup("Bairro: " + feature.properties.PATH + "
GEO: " + feature.properties.GEO_KEY + "
zoneamento: " + feature.properties.ZONEAMENTO + "
área: " + feature.properties.AREA + "
regularidade: " + regularidade + "
Pesquisa Imóveis"); if (layer.feature.geometry.type=="MultiPolygon"){ if ('pontoEnergia' in feature.properties){ //layer.bindTooltip("my tooltip text").openTooltip(); //regColor = "green"; regFillColor = "white"; } layer.setStyle({"fillColor":regFillColor, "weight":1, "opacity":1, "color":regColor, "fillOpacity":0.3, "dashArray":dash}); if (feature.properties.siat=="N"){ //layer.bindTooltip("my tooltip text").openTooltip(); layer.setStyle({"fillColor":"white","color":"black","weight":5}); } else if (feature.properties.siat=="D"){ //layer.bindTooltip("my tooltip text").openTooltip(); layer.setStyle({"fillColor":"black","color":"black","weight":5}); } if (feature.properties.maisConstrucao=="S"){ //layer.bindTooltip("my tooltip text").openTooltip(); layer.setStyle({"weight":5}); } } else if (layer.feature.geometry.type=="Point" && 'lote' in layer.feature.properties){ //layer.setStyle({"opacity":0.5,"outline":"dashed"}); layer.options['opacity']=0.5; } } }).addTo(groupMarker); map_layers[camada].addLayer(groupMarker); } } map.setView(loc, 14); if (document.getElementById('legenda')=== null){ var legend = L.control({position: 'topleft'}); legend.onAdd = function (map) { var div = L.DomUtil.create('div', 'leaflet-control leaflet-control-layers'); div.style = `#position: absolute; #top: 50%; align:left;`; div.id = 'legenda'; div.innerHTML = '
    Siat:OK
'+ '
    sem titular
'+ '
    territorial
'+ '
    territorial+sem titular
'+ '
    Diverge em área de terreno no SIAT
'+ '
    Inexistente no SIAT
'+ '
    linha grossa continua : sem lote no Siat
'+ '
    linha grossa intercalada : mais construção Siat
'; return div; }; legend.addTo(map); } } else if(e.name == "Dados Enviados"){ document.getElementById("info-back").style.display = "none"; stopRot(); var groupMarker = new L.MarkerClusterGroup({ disableClusteringAtZoom: 18, showCoverageOnHover: true, zoomToBoundsOnClick: true, spiderfyOnMaxZoom: true }); $.each(dadosenviados.features, function(a){ if(dadosenviados.features[a].geometry!=null){ if(dadosenviados.features[a].geometry.type=="Point"){ var coordinates = dadosenviados.features[a].geometry.coordinates; }else if(dadosenviados.features[a].geometry.type=="LineString"){ var coordinates = dadosenviados.features[a].geometry.coordinates[0]; }else if(dadosenviados.features[a].geometry.type=="Polygon"){ var coordinates = dadosenviados.features[a].geometry.coordinates[0][0]; }else{ var coordinates = dadosenviados.features[a].geometry.coordinates[0][0][0]; } var loc = new L.LatLng(coordinates[1], coordinates[0]); if (dadosenviados.features[a].properties.Tipo=="QGIS"){ //L.marker(loc,{icon:marker[20], alt:(JSON.stringify(dadosenviados.features[a].properties))}).bindPopup("Titulo: " + dadosenviados.features[a].properties.Titulo + "
Dados: "+JSON.stringify(dadosenviados.features[a].properties)).addTo(map).openPopup(); } else if (dadosenviados.features[a].properties.KEY===0){ L.marker(loc,{icon:marker[5], alt:(JSON.stringify(dadosenviados.features[a].properties))}).bindPopup("Geo: " + dadosenviados.features[a].properties.GEO_KEY + "
Guia de ITBI: " + dadosenviados.features[a].properties.BUSCA).addTo(map).openPopup(); } else if (dadosenviados.features[a].properties.KEY>0){ L.marker(loc,{icon:marker[6], alt:(JSON.stringify(dadosenviados.features[a].properties))}).bindTooltip("Geo: " + dadosenviados.features[a].properties.GEO_KEY + "
Guia de ITBI: " + dadosenviados.features[a].properties.BUSCA).addTo(groupMarker); } } }); L.geoJSON(dadosenviados,{onEachFeature: function(feature, layer){ poptxt=""; for (const [key, value] of Object.entries(feature.properties)){ poptxt+=`${key}: ${value}
` } layer.bindTooltip(poptxt); var regFillColor = "blue"; var regColor = "blue"; if (feature.properties.semtitular=="S" && feature.properties.territorial=="S"){ regFillColor = "purple"; regColor = "red"; } else if (feature.properties.semtitular=="S" && feature.properties.territorial=="N"){ regFillColor = "yellow"; regColor = "red"; } else if ((feature.properties.semtitular=="N" || feature.properties.semtitular===undefined ) && feature.properties.territorial=="S"){ regFillColor = "brown"; regColor = "red"; } if (feature.properties.maisConstrucao=="S"){ //dash=",stroke-dasharray='16'"; dash="6 20"; } else { //dash=",stroke-dasharray='0'"; dash="0"; } //layer.bindPopup("Bairro: " + feature.properties.PATH + "
GEO: " + feature.properties.GEO_KEY + "
zoneamento: " + feature.properties.ZONEAMENTO + "
área: " + feature.properties.AREA + "
regularidade: " + regularidade + "
Pesquisa Imóveis"); if (layer.feature.geometry.type=="MultiPolygon"){ layer.setStyle({"fillColor":regFillColor, "weight":1, "opacity":1, "color":regColor, "fillOpacity":0.3, "dashArray":dash}); if (feature.properties.siat=="N"){ //layer.bindTooltip("my tooltip text").openTooltip(); layer.setStyle({"fillColor":"white","color":"black","weight":5}); } else if (feature.properties.siat=="D"){ //layer.bindTooltip("my tooltip text").openTooltip(); layer.setStyle({"fillColor":"black","color":"black","weight":5}); } if (feature.properties.maisConstrucao=="S"){ //layer.bindTooltip("my tooltip text").openTooltip(); layer.setStyle({"weight":5}); } } } }).addTo(groupMarker); map_layers["Dados Enviados"].addLayer(groupMarker); /* var legend = L.control({position: 'bottomright'}); legend.onAdd = function (map) { var div = L.DomUtil.create('div', 'leaflet-bar leaflet-control info legend'); div.innerHTML = 'Siat:OK
'+ 'sem titular
'+ 'territorial
'+ 'territorial+sem titular
'+ 'linha grossa continua sem lote no Siat
'+ 'linha grossa intercalada mais construção Siat
'; return div; }; legend.addTo(map); */ }else if(e.name == "Corona Vírus"){ $.getJSON(dir + "json/maceiogeocorona.php", function(geoinfo){ $("#info-back").fadeOut("slow"); stopRot(); var groupMarker = new L.MarkerClusterGroup({ disableClusteringAtZoom: 20, showCoverageOnHover: true, zoomToBoundsOnClick: true, spiderfyOnMaxZoom: true }); $.each(geoinfo.features, function(a){ var coordinates = geoinfo.features[a].geometry.coordinates; var loc = new L.LatLng(coordinates[1], coordinates[0]); L.marker(loc,{icon:marker[16], alt:(JSON.stringify(geoinfo.features[a].properties))}).on('click', showCorona).addTo(groupMarker); }); map_layers["Corona Vírus"].addLayer(groupMarker); }); }else if(e.name == "Mapa de Calor"){ $.getJSON(dir + "json/maceiogeocorona.php", function(geoinfo){ let fuentesPoints = []; $("#info-back").fadeOut("slow"); stopRot(); var groupMarker2 = new L.layerGroup(); $.each(geoinfo.features, function(a){ var coordinates = geoinfo.features[a].geometry.coordinates; fuentesPoints.push([coordinates[1],coordinates[0],20]); }); // https://github.com/Leaflet/Leaflet.heat // https://observablehq.com/@serman/leaflet-example-map-pins-heatmap let fuentesLayer = L.heatLayer(fuentesPoints).addTo(groupMarker2); map_layers["Mapa de Calor"].addLayer(groupMarker2); }); }else{ $.getJSON(dir + "json/" + e.name + ".json", function(geoinfo){ $("#info-back").fadeOut("slow"); stopRot(); L.geoJSON(geoinfo, { onEachFeature: function (feature, layer) { if(e.name === "Bairros"){ layer.bindPopup("Bairro: " + feature.properties.BAIRRO + "
Pesquisa Imóveis"); layer.setStyle({fillColor:'blue', weight:3, opacity:1, color:'#0D81AB', fillOpacity:0.1}); }else if(e.name == "Imóveis Municipais"){ layer.bindPopup("Bairro: " + feature.properties.PATH + "
GEO: " + feature.properties.GEO_KEY + "
zoneamento: " + feature.properties.ZONEAMENTO + "
área: " + feature.properties.AREA + "
Pesquisa Imóveis"); layer.setStyle({fillColor:'blue', weight:1, opacity:1, color:'#000000', dashArray:'1', fillOpacity:0.1}); }else if(e.name == "Zoneamento Alto-Risco" || e.name == "Zoneamento"){// layer.bindPopup("Zoneamento: " + feature.properties.zoneamento); cor_random=generateRandomHex(); layer.setStyle({fillColor:cor_random, weight:2, opacity:1, color:'#0F0000', dashArray:'1', fillOpacity:0.3}); }else if(e.name == "Correios"){ layer.bindPopup("Cep Correios: " + feature.properties.cep + "
Logradouro: " + feature.properties['nome_logra']); layer.setStyle({fillColor:'blue', weight:2, opacity:1, color:'#F00000', dashArray:'1', fillOpacity:0.1}); }else if(e.name == "Vias Oficial"){ layer.bindPopup("Cep: " + feature.properties.CEP + "
Logradouro: " + feature.properties['nome']); layer.setStyle({fillColor:'blue', weight:2, opacity:1, color:'#0F0000', dashArray:'1', fillOpacity:0.1}); }else if(e.name == "Circunscrição Cartórios"){ layer.bindPopup("Cartório: " + feature.properties.Cartório); cor_random=generateRandomHex(); layer.setStyle({fillColor:cor_random, weight:2, opacity:1, color:'#0F0000', dashArray:'1', fillOpacity:0.3}); }else if(e.name == "Lotes Territoriais"){ layer.layerID = popupId; layer.bindPopup("Bairro: " + feature.properties.PATH + "
GEO: " + feature.properties.GEO_KEY + "
zoneamento: " + feature.properties.ZONEAMENTO + "
área: " + feature.properties.AREA + "
Há construção
Não edificado
Pesquisa Imóveis"); if(localStorage !== null){ localStorage.forEach((data) => { if(layer.layerID == data.id){ if(data.edif == "S"){ layer.setStyle({fillColor:'red', weight: 1, opacity:1, color:'#FFFF00', dashArray:'1', fillOpacity:0.4}); auxiliar = 1; } else { layer.setStyle({fillColor:'yellow', weight: 1, opacity:1, color:'#FF0000', dashArray:'1', fillOpacity:0.4}); auxiliar = 1; } } }); } if(auxiliar == 0){ layer.setStyle({fillColor:'blue', weight:1, opacity:1, color:'#000000', dashArray:'1', fillOpacity:0.1}); } auxiliar = 0; popupId++; }else if(e.name == "Lei de incentivo do Jaraguá"){ layer.bindPopup("Bairro: " + feature.properties.PATH + "
GEO: " + feature.properties.GEO_KEY + "
zoneamento: " + feature.properties.ZONEAMENTO + "
área: " + feature.properties.AREA + "
Pesquisa Imóveis"); layer.setStyle({fillColor:'blue', weight:1, opacity:1, color:'#23BED6', dashArray:'1', fillOpacity:0.1}); }else if(e.name == "Regularidade do Jaraguá"){ switch(feature.properties.REGULARIDADE){ case 0: var regFillColor = "red"; var regColor = "red"; var regularidade = "Sem Regularidade"; break; case 1: var regFillColor = "blue"; var regColor = "blue"; var regularidade = "Regularizado"; break; case 2: var regFillColor = "black"; var regColor = "black"; var regularidade = "Múltiplas Inscrições"; break; } layer.bindPopup("Bairro: " + feature.properties.PATH + "
GEO: " + feature.properties.GEO_KEY + "
zoneamento: " + feature.properties.ZONEAMENTO + "
área: " + feature.properties.AREA + "
regularidade: " + regularidade + "
Pesquisa Imóveis"); layer.setStyle({fillColor:regFillColor, weight:1, opacity:1, color:regColor, dashArray:'1', fillOpacity:0.3}); }else if(e.name == "Evento geológico do Pinheiro"){ layer.bindPopup("Setor: " + feature.properties.SUB_SETOR + "
Pesquisa Imóveis"); layer.setStyle({fillColor:'blue', weight:1, opacity:1, color:'#23BED6', dashArray:'1', fillOpacity:0.1}); } else if(e.name == "Quadras"){ txtset=feature.properties.setor.toString().padStart(2, `0`); txtquad=feature.properties.quadra.toString().padStart(4, `0`); layer.bindPopup("Bairro: " + feature.properties.bairro + "
Setor: " + feature.properties.setor + "
Quadra: " + txtquad + "
Pesquisa Imóveis"); layer.setStyle({fillColor:'blue', weight:1, opacity:1, color:'#23BED6', dashArray:'1', fillOpacity:0.1}).on('click', showLocation); } } }).addTo(map_layers[e.name]); }); } if(e.name != "Dados Enviados" && !(camadas_enviadas.includes(e.name))){startRot()}; } }else{ if(map_layers[key].getLayers().length === 0){ $.getJSON(dir + "json/maceiogeoinfo.php?conn=R&tipo=" + key, function(geoinfo){ $("#info-back").fadeOut("slow"); stopRot(); if(Object.keys(geoinfo).length > 0){ if(key <= 50){ var groupMarker = new L.MarkerClusterGroup({ disableClusteringAtZoom: 17, showCoverageOnHover: true, zoomToBoundsOnClick: true, spiderfyOnMaxZoom: false }); }else{ var groupMarker = new L.MarkerClusterGroup({ showCoverageOnHover: true, zoomToBoundsOnClick: true, spiderfyOnMaxZoom: true }); } $.each(geoinfo.features, function(a){ if(geoinfo.features[a].geometry.type == "Point"){ var coordinates = geoinfo.features[a].geometry.coordinates; var loc = new L.LatLng(coordinates[1], coordinates[0]); L.marker(loc,{icon:marker[tipos[key]["marker"]], alt:(JSON.stringify(geoinfo.features[a].properties))}).on('click', showLocation).addTo(groupMarker); }else if (geoinfo.features[a].geometry.type == "LineString"){ L.geoJSON(geoinfo.features[a], { onEachFeature: function(feature, layer){ layer.setStyle({fillColor:'red', weight:3, opacity:1, color:'#800000', fillOpacity:0.2}); } }).addTo(map_layers[key]); }else{ L.geoJSON(geoinfo.features[a], { onEachFeature: function(feature, layer){ layer.setStyle({fillColor:'blue', weight:2, opacity:1, color:'#0D81AB', fillOpacity:0.1}); layer.bindTooltip(feature.properties.Descricao); } }).on('click', showLocation).addTo(map_layers[key]); } }); map_layers[key].addLayer(groupMarker); }else{ errMsg(["Não há informação para a pesquisa de " + e.name]); } }); startRot(); } } }); //SIZE CORRECTION map.invalidateSize(true); }); //SIZE CORRECTION map.invalidateSize(true); }); function checkValue(value, edf){ if(document.querySelector("#"+ value.id +"").checked == true){ $("#myModal").animate({opacity: 1}, "fast", function(){ var edif = value.id; var desmarcar = value.id; edif = edif.substr(-1); idPopup = value.id; edifPopup = edf; if(edif == "S"){ var desmarcar = value.id; desmarcar = desmarcar.substring(0,(desmarcar.length - 1)) + "N"; if(document.querySelector("#"+ desmarcar +"").checked == true){ document.querySelector("#"+ desmarcar +"").checked = false; } }else{ var desmarcar = value.id; desmarcar = desmarcar.substring(0,(desmarcar.length - 1)) + "S"; if(document.querySelector("#"+ desmarcar +"").checked == true){ document.querySelector("#"+ desmarcar +"").checked = false; } } if(checarNome == 0){ document.getElementById("myModal").style.display = "block"; checarNome = 1; }else{ salvarStorage(); } }); } } function spanClick(){ document.getElementById("myModal").style.display = "none"; } function salvarStorage(){ if(document.getElementById("nomeUsuario").value == "" || document.getElementById("nomeUsuario").value == null){ console.log("Digite seu nome"); }else{ let pontosMarcados = new Array(); let x = map_layers['Lotes Territoriais'].getLayers(); let y = x[0]._layers; let layerId = idPopup.split("-"); let layeredif = 0; let edifValue; layeredif = layerId[2]; layerId = layerId[1]; switch(edifPopup){ case 1: edifValue = "S"; break; case 2: edifValue = "N"; break; } Object.entries(y).forEach((layer) => { if(layer[1].layerID == layerId){ if (localStorage.hasOwnProperty("idPontos")) { let storage = JSON.parse(localStorage.getItem("idPontos")); let auxiliar = 0; let auxiliarArray = 0; storage.forEach((data) => { if(data.id == layerId && data.edif == edifValue){ console.log("O ponto já foi marcado anteriormente"); auxiliar = 1; }else if(data.id == layerId && data.edif !== edifValue){ storage.shift(auxiliarArray); auxiliar = 0; auxiliarArray--; } auxiliarArray++; }); if(auxiliar == 0){ pontosMarcados = storage; pontosMarcados.push({id: layerId, nome: document.getElementById("nomeUsuario").value, edif:layeredif}); window.localStorage.setItem('idPontos', JSON.stringify(pontosMarcados)); if(edifValue == "S"){ layer[1].setStyle({fillColor:'red', color:'#FFFF00', fillOpacity:0.4}); }else{ layer[1].setStyle({fillColor:'yellow', color:'#FF0000', fillOpacity:0.4}); } enviarDados(document.getElementById("nomeUsuario").value ,layerId, edifValue); console.log("Polígono atualizado."); } }else{ pontosMarcados.push({id: layerId, nome: document.getElementById("nomeUsuario").value, edif:layeredif}); window.localStorage.setItem('idPontos', JSON.stringify(pontosMarcados)); if(edifValue == "S"){ layer[1].setStyle({fillColor:'red', color:'#FFFF00', fillOpacity:0.4}); }else{ layer[1].setStyle({fillColor:'yellow', color:'#FF0000', fillOpacity:0.4}); } enviarDados(document.getElementById("nomeUsuario").value ,layerId, edifValue); console.log("Polígono atualizado."); } } }); document.getElementById("myModal").style.display = "none"; } } function enviarDados(nome, id, edif){ var http = new XMLHttpRequest(); var url = 'https://semecmaceio.com/maceio-geo/json/maceiogeocrossing.php'; var data = '{"name": "'+ nome +'", "id": '+ id +', "edif": "'+ edif +'"}'; var params = new Array(); params.push(data); http.open('POST', url, true); //Send the proper header information along with the request http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { console.log("resposta: ", http.responseText); } } http.send(params); }