|
@ -160,7 +160,7 @@ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$("#clear-filters").click(function(event) { |
|
|
$(".clear-filters").click(function(event) { |
|
|
event.preventDefault(); |
|
|
event.preventDefault(); |
|
|
$("input[type=checkbox][name=tipo_orgao]").prop('checked', false); |
|
|
$("input[type=checkbox][name=tipo_orgao]").prop('checked', false); |
|
|
$("input[type=checkbox][name=tipo_servico]").prop('checked', false); |
|
|
$("input[type=checkbox][name=tipo_servico]").prop('checked', false); |
|
@ -170,7 +170,7 @@ |
|
|
$("input[type=checkbox][name=gerente]").prop('checked', false); |
|
|
$("input[type=checkbox][name=gerente]").prop('checked', false); |
|
|
filtra(); |
|
|
filtra(); |
|
|
}); |
|
|
}); |
|
|
$("#center-map").click(function(event) { |
|
|
$(".center-map").click(function(event) { |
|
|
event.preventDefault(); |
|
|
event.preventDefault(); |
|
|
mymap.flyTo(map_center, 4.5); |
|
|
mymap.flyTo(map_center, 4.5); |
|
|
}); |
|
|
}); |
|
@ -192,178 +192,5 @@ |
|
|
mark.openPopup(); |
|
|
mark.openPopup(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
{% endblock %} |
|
|
{% endblock %} |
|
|
|
|
|
|
|
|
{% comment %} |
|
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl" |
|
|
|
|
|
{% endif %}> |
|
|
|
|
|
|
|
|
|
|
|
<head> |
|
|
|
|
|
<title>{% trans 'SIGI' %}</title> |
|
|
|
|
|
|
|
|
|
|
|
</head> |
|
|
|
|
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
<div class="mapbox"> |
|
|
|
|
|
<div class="sigi-logo"> |
|
|
|
|
|
<div> |
|
|
|
|
|
<img src="{% static 'img/interlegis_60x60.png' %}" class='img-circle' /> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div> |
|
|
|
|
|
<h3>Interlegis</h3> |
|
|
|
|
|
<a href="{% url 'admin:index' %}">Voltar ao SIGI</a> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div id="map"> |
|
|
|
|
|
<!-- open street map --> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
<script> |
|
|
|
|
|
$(document).ready(function () { |
|
|
|
|
|
var options = { color: 'blue', fillColor: 'red', fillOpacity: 0.4, radius: 500 }; |
|
|
|
|
|
var unfiltred_options = { color: 'red', fillColor: 'red', fillOpacity: 0, radius: 1000 }; |
|
|
|
|
|
|
|
|
|
|
|
$("#search-text").autocomplete({ |
|
|
|
|
|
minLength: 3, |
|
|
|
|
|
source: function (request, response) { |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
url: "{% url "openmapsearch" %}", |
|
|
|
|
|
data: { q: request.term }, |
|
|
|
|
|
dataType: "json", |
|
|
|
|
|
appendTo: "#searchform", |
|
|
|
|
|
success: function (data) { |
|
|
|
|
|
console.log(data); |
|
|
|
|
|
response(data); |
|
|
|
|
|
}, |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
select: function (event, ui) { |
|
|
|
|
|
mymap.flyTo([ui.item.lat, ui.item.lng], 8.5); |
|
|
|
|
|
var encontrado = false; |
|
|
|
|
|
mymap.eachLayer(function (layer) { |
|
|
|
|
|
if (layer instanceof L.Circle) { |
|
|
|
|
|
if (layer.orgao_id == ui.item.id) { |
|
|
|
|
|
layer.openPopup(); |
|
|
|
|
|
encontrado = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
if (!encontrado) { |
|
|
|
|
|
var mark = L.circle([ui.item.lat, ui.item.lng], unfiltred_options).bindTooltip(ui.item.label).bindPopup("").addTo(mymap); |
|
|
|
|
|
mark.orgao_id = ui.item.id |
|
|
|
|
|
mark.openPopup(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log(ui); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
$("#filterbox").on("shown.bs.collapse", function () { |
|
|
|
|
|
$("#options-toggler span").removeClass("glyphicon-chevron-right").addClass("glyphicon-chevron-left") |
|
|
|
|
|
}) |
|
|
|
|
|
$("#filterbox").on("hidden.bs.collapse", function () { |
|
|
|
|
|
$("#options-toggler span").removeClass("glyphicon-chevron-left").addClass("glyphicon-chevron-right") |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
$("input[type=checkbox]").change(filtra); |
|
|
|
|
|
|
|
|
|
|
|
var mymap = L.map('map', { zoomSnap: 0.01 }).setView([-14.235004, -51.92528], 4.5); |
|
|
|
|
|
|
|
|
|
|
|
mymap.zoomControl.options.zoomInTitle = "{% trans 'Aproximar' %}"; |
|
|
|
|
|
mymap.zoomControl.options.zoomOutTitle = "{% trans 'Afastar' %}"; |
|
|
|
|
|
mymap.zoomControl.setPosition("bottomright"); |
|
|
|
|
|
|
|
|
|
|
|
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', { |
|
|
|
|
|
maxZoom: 18, |
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, ' + |
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>', |
|
|
|
|
|
id: 'mapbox/streets-v11', |
|
|
|
|
|
tileSize: 512, |
|
|
|
|
|
zoomOffset: -1 |
|
|
|
|
|
}).addTo(mymap); |
|
|
|
|
|
|
|
|
|
|
|
mymap.on("popupopen", function (e) { |
|
|
|
|
|
var popup = e.popup; |
|
|
|
|
|
mark = popup._source; |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
type: "GET", |
|
|
|
|
|
url: "{% url "openmapdetail" 'orgao_id' %}".replace("orgao_id", mark.orgao_id), |
|
|
|
|
|
encode: true |
|
|
|
|
|
}).done(function (content) { |
|
|
|
|
|
popup.setContent(content); |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
filtra(); |
|
|
|
|
|
|
|
|
|
|
|
function filtra() { |
|
|
|
|
|
var name = $(this).attr("name"), |
|
|
|
|
|
value = $(this).attr("value"), |
|
|
|
|
|
checked = $(this).prop("checked"); |
|
|
|
|
|
|
|
|
|
|
|
if (value == "ignore") { |
|
|
|
|
|
controls = $(this).attr("data-controls"); |
|
|
|
|
|
$("input[type=checkbox][name='" + controls + "']").prop("disabled", checked); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (value == "none") { |
|
|
|
|
|
$("input[type=checkbox][name='" + name + "'][value!='none']").prop("checked", !checked); |
|
|
|
|
|
} else { |
|
|
|
|
|
if (checked) { |
|
|
|
|
|
$("input[type=checkbox][name='" + name + "'][value='none']").prop("checked", false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (name = 'regiao') { |
|
|
|
|
|
$("input[type=checkbox][name='uf'][data-regiao='" + value + "']").prop('checked', checked); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (name = 'uf') { |
|
|
|
|
|
var sigla_regiao = $(this).attr('data-regiao'), |
|
|
|
|
|
regiao = $("input[type=checkbox][value='" + sigla_regiao + "']"); |
|
|
|
|
|
if ($("input[type=checkbox][name='uf'][data-regiao='" + sigla_regiao + "']:checked").length == 0) { |
|
|
|
|
|
$(regiao).prop('checked', false).prop("indeterminate", false); |
|
|
|
|
|
} else if ($("input[type=checkbox][name='uf'][data-regiao='" + sigla_regiao + "']:not(:checked)").length == 0) { |
|
|
|
|
|
$(regiao).prop('checked', true).prop("indeterminate", false); |
|
|
|
|
|
} else { |
|
|
|
|
|
$(regiao).prop("indeterminate", true) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var formData = $("#filterForm").serializeArray(); |
|
|
|
|
|
|
|
|
|
|
|
mymap.eachLayer(function (layer) { |
|
|
|
|
|
if (layer instanceof L.Circle) { |
|
|
|
|
|
mymap.removeLayer(layer); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
type: "GET", |
|
|
|
|
|
url: "{% url "openmapdata" %}", |
|
|
|
|
|
data: formData, |
|
|
|
|
|
dataType: "json", |
|
|
|
|
|
encode: true, |
|
|
|
|
|
}).done(function (returnedData) { |
|
|
|
|
|
$("#totalOrgao").text(returnedData.length); |
|
|
|
|
|
returnedData.forEach(function (casa) { |
|
|
|
|
|
if (casa[2] === null || casa[3] === null) { |
|
|
|
|
|
alert(casa[1] + " está sem coordenadas geográficas e não será plotada"); |
|
|
|
|
|
} else { |
|
|
|
|
|
var mark = L.circle([casa[2], casa[3]], options).bindTooltip(casa[1]).bindPopup("").addTo(mymap); |
|
|
|
|
|
mark.orgao_id = casa[0] |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
</script> |
|
|
|
|
|
</body> |
|
|
|
|
|
|
|
|
|
|
|
</html> |
|
|
|
|
|
|
|
|
|
|
|
{% endcomment %} |
|
|
|