2016-01-15 11:53:00 +01:00
|
|
|
function qp_active() {
|
2017-04-04 16:15:33 +02:00
|
|
|
return $("#map.qp").length > 0
|
2016-01-15 11:53:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_qp(coordinates) {
|
2017-04-04 16:15:33 +02:00
|
|
|
if (!qp_active())
|
|
|
|
return;
|
|
|
|
|
|
|
|
var qp;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
method: 'post',
|
|
|
|
url: '/users/dossiers/' + dossier_id + '/carte/qp',
|
|
|
|
data: {coordinates: JSON.stringify(coordinates)},
|
|
|
|
dataType: 'json',
|
|
|
|
async: false
|
|
|
|
}).done(function (data) {
|
|
|
|
qp = data
|
|
|
|
});
|
|
|
|
|
|
|
|
return qp['quartier_prioritaires'];
|
2016-01-15 11:53:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function display_qp(qp_list) {
|
2017-04-04 16:15:33 +02:00
|
|
|
if (!qp_active())
|
|
|
|
return;
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
qp_array = jsObject_to_array(qp_list);
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
$("#qp.list ul").html('');
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
new_qpLayer();
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
if (qp_array.length > 0) {
|
|
|
|
qp_array.forEach(function (qp) {
|
|
|
|
$("#qp.list ul").append('<li>' + qp.commune + ' : ' + qp.nom + '</li>');
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
qpItems.addData(qp.geometry);
|
|
|
|
});
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
qpItems.setStyle({
|
|
|
|
fillColor: '#31708f',
|
|
|
|
weight: 2,
|
|
|
|
opacity: 0.3,
|
|
|
|
color: 'white',
|
|
|
|
dashArray: '3',
|
|
|
|
fillOpacity: 0.7
|
|
|
|
})
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$("#qp.list ul").html('<li>AUCUN</li>');
|
2016-01-15 11:53:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function new_qpLayer() {
|
2017-04-04 16:15:33 +02:00
|
|
|
if (typeof qpItems != 'undefined')
|
|
|
|
map.removeLayer(qpItems);
|
2016-01-15 11:53:00 +01:00
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
qpItems = new L.GeoJSON();
|
|
|
|
qpItems.addTo(map);
|
2017-04-04 15:27:04 +02:00
|
|
|
}
|