Merge branch 'develop' into refactor_type_de_xxx
Conflicts: db/schema.rb
This commit is contained in:
commit
d6e4a76bf9
73 changed files with 1352 additions and 212 deletions
|
@ -18,4 +18,10 @@
|
|||
//= require bootstrap-sprockets
|
||||
//= require bootstrap-datepicker/core
|
||||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js
|
||||
//= require leaflet
|
||||
|
||||
//= require leaflet.js
|
||||
//= require d3.min
|
||||
//= require clipper
|
||||
//= require concavehull.min
|
||||
//= require graham_scan.min
|
||||
//= require leaflet.freedraw
|
||||
|
|
|
@ -1,10 +1,64 @@
|
|||
//récupération de la position de l'entreprise
|
||||
function initCarto() {
|
||||
OSM = L.tileLayer("http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", {
|
||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
});
|
||||
|
||||
function get_position(){
|
||||
var LON = '2.428462';
|
||||
var LAT = '46.538192';
|
||||
|
||||
position = get_position() || {lon: LON, lat: LAT, zoom: 13};
|
||||
|
||||
if (typeof position.zoom == 'undefined')
|
||||
position.zoom = 13;
|
||||
|
||||
var map = L.map("map", {
|
||||
center: new L.LatLng(position.lat, position.lon),
|
||||
zoom: position.zoom,
|
||||
layers: [OSM]
|
||||
});
|
||||
|
||||
var freeDraw = new L.FreeDraw({
|
||||
//mode: L.FreeDraw.MODES.CREATE
|
||||
});
|
||||
|
||||
map.addLayer(freeDraw);
|
||||
|
||||
if ($("#json_latlngs").val() != '' && $("#json_latlngs").val() != '[]') {
|
||||
$.each($.parseJSON($("#json_latlngs").val()), function (i, val) {
|
||||
freeDraw.createPolygon(val);
|
||||
});
|
||||
|
||||
map.fitBounds(freeDraw.polygons[0].getBounds());
|
||||
}
|
||||
else if (position.lat == LAT && position.lon == LON)
|
||||
map.setView(new L.LatLng(position.lat, position.lon), 5);
|
||||
|
||||
add_event_freeDraw(freeDraw);
|
||||
}
|
||||
|
||||
function add_event_freeDraw(freeDraw) {
|
||||
freeDraw.on('markers', function (e) {
|
||||
$("#json_latlngs").val(JSON.stringify(e.latLngs));
|
||||
});
|
||||
|
||||
$("#new").on('click', function (e) {
|
||||
freeDraw.setMode(L.FreeDraw.MODES.CREATE);
|
||||
});
|
||||
|
||||
$("#edit").on('click', function (e) {
|
||||
freeDraw.setMode(L.FreeDraw.MODES.EDIT);
|
||||
});
|
||||
|
||||
$("#delete").on('click', function (e) {
|
||||
freeDraw.setMode(L.FreeDraw.MODES.DELETE);
|
||||
});
|
||||
}
|
||||
|
||||
function get_position() {
|
||||
var position;
|
||||
|
||||
$.ajax({
|
||||
url: '/users/dossiers/'+dossier_id+'/carte/position',
|
||||
url: '/users/dossiers/' + dossier_id + '/carte/position',
|
||||
dataType: 'json',
|
||||
async: false
|
||||
}).done(function (data) {
|
||||
|
@ -12,23 +66,4 @@ function get_position(){
|
|||
});
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
function get_ref_dossier (){
|
||||
$.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) {
|
||||
if (window.location.href.indexOf('carte') > -1 && window.featureCollection.features.length == 0) {
|
||||
$("#flash_message").html('<div class="alert alert-danger">Un dessin est obligatoire.</div>');
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue