2015-08-10 11:05:06 +02:00
|
|
|
//récupération de la position de l'entreprise
|
|
|
|
|
2015-11-10 18:08:47 +01:00
|
|
|
function initCarto() {
|
|
|
|
OSM = L.tileLayer("http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", {
|
|
|
|
attribution: '© Openstreetmap France | © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
|
|
});
|
|
|
|
|
|
|
|
position = get_position();
|
|
|
|
|
|
|
|
var map = L.map("map", {
|
|
|
|
center: new L.LatLng(position.lat, position.lon),
|
|
|
|
zoom: 13,
|
|
|
|
layers: [OSM]
|
|
|
|
});
|
|
|
|
|
|
|
|
freeDraw = new L.FreeDraw({
|
|
|
|
mode: L.FreeDraw.MODES.CREATE
|
|
|
|
});
|
|
|
|
|
|
|
|
map.addLayer(freeDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_position() {
|
2015-08-10 11:05:06 +02:00
|
|
|
var position;
|
|
|
|
|
|
|
|
$.ajax({
|
2015-11-10 18:08:47 +01:00
|
|
|
url: '/users/dossiers/' + dossier_id + '/carte/position',
|
2015-08-10 11:05:06 +02:00
|
|
|
dataType: 'json',
|
|
|
|
async: false
|
|
|
|
}).done(function (data) {
|
|
|
|
position = data
|
|
|
|
});
|
|
|
|
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
2015-11-10 18:08:47 +01:00
|
|
|
function get_ref_dossier() {
|
2015-08-10 11:05:06 +02:00
|
|
|
$.post("http://apicarto.coremaps.com/api/v1/datastore", {
|
|
|
|
contentType: "application/json",
|
|
|
|
dataType: 'json',
|
|
|
|
geom: JSON.stringify(window.featureCollection.features[0]),
|
|
|
|
ascyn: false
|
|
|
|
}).done(function (data) {
|
|
|
|
$("#ref_dossier").val(data.reference);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function submit_check_draw(e) {
|
2015-08-12 10:38:34 +02:00
|
|
|
if (window.location.href.indexOf('carte') > -1 && window.featureCollection.features.length == 0) {
|
2015-08-10 11:05:06 +02:00
|
|
|
$("#flash_message").html('<div class="alert alert-danger">Un dessin est obligatoire.</div>');
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|