2016-01-15 11:53:00 +01:00
|
|
|
|
function cadastre_active() {
|
2017-04-04 16:15:33 +02:00
|
|
|
|
return $("#map.cadastre").length > 0
|
2016-01-15 11:53:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_cadastre(coordinates) {
|
2017-04-04 16:15:33 +02:00
|
|
|
|
if (!cadastre_active())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var cadastre;
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
method: 'post',
|
|
|
|
|
url: '/users/dossiers/' + dossier_id + '/carte/cadastre',
|
|
|
|
|
data: {coordinates: JSON.stringify(coordinates)},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: false
|
|
|
|
|
}).done(function (data) {
|
|
|
|
|
cadastre = data
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return cadastre['cadastres'];
|
2016-01-15 11:53:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 14:01:02 +01:00
|
|
|
|
function display_cadastre(cadastre_array) {
|
2017-04-04 16:15:33 +02:00
|
|
|
|
if (!cadastre_active())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
$("#cadastre.list ul").html('');
|
|
|
|
|
new_cadastreLayer();
|
|
|
|
|
|
|
|
|
|
if (cadastre_array.length == 1 && cadastre_array[0]['zoom_error'])
|
|
|
|
|
$("#cadastre.list ul").html('<li><b>Merci de dessiner une surface plus petite afin de récupérer les parcelles cadastrales.</b></li>');
|
|
|
|
|
|
|
|
|
|
else if (cadastre_array.length > 0) {
|
|
|
|
|
cadastre_array.forEach(function (cadastre) {
|
2017-04-06 18:16:11 +02:00
|
|
|
|
$("#cadastre.list ul").append('<li> Parcelle nº ' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '</li>');
|
2017-04-04 16:15:33 +02:00
|
|
|
|
|
|
|
|
|
cadastreItems.addData(cadastre.geometry);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cadastreItems.setStyle({
|
|
|
|
|
fillColor: '#8a6d3b',
|
|
|
|
|
weight: 2,
|
|
|
|
|
opacity: 0.3,
|
|
|
|
|
color: 'white',
|
|
|
|
|
dashArray: '3',
|
|
|
|
|
fillOpacity: 0.7
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$("#cadastre.list ul").html('<li>AUCUN</li>');
|
2016-01-15 11:53:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function new_cadastreLayer() {
|
2017-04-04 16:15:33 +02:00
|
|
|
|
if (typeof cadastreItems != 'undefined')
|
|
|
|
|
map.removeLayer(cadastreItems);
|
2016-01-15 11:53:00 +01:00
|
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
|
cadastreItems = new L.GeoJSON();
|
|
|
|
|
cadastreItems.addTo(map);
|
2017-04-04 15:27:04 +02:00
|
|
|
|
}
|