Display cadastre on map if present on database

This commit is contained in:
Xavier J 2016-01-18 14:45:08 +01:00
parent 6a3525c7e2
commit 72043dbe56
3 changed files with 16 additions and 10 deletions

View file

@ -8,22 +8,27 @@ function initCarto() {
position = get_position() || default_position();
if (position.lon == "0" && position.lat == "0")
position = default_position();
if (typeof position.zoom == 'undefined')
position.zoom = 13;
map = L.map("map", {
center: new L.LatLng(position.lat, position.lon),
zoom: position.zoom,
layers: [OSM]
});
if (qp_active())
display_qp(JSON.parse($("#quartier_prioritaires").val()));
if (cadastre_active())
display_cadastre(JSON.parse($("#cadastres").val()));
freeDraw = new L.FreeDraw();
freeDraw.options.setSmoothFactor(4);
freeDraw.options.simplifyPolygon = false;
map.addLayer(freeDraw);
if ($("#json_latlngs").val() != '' && $("#json_latlngs").val() != '[]') {
map.setZoom(18);
$.each($.parseJSON($("#json_latlngs").val()), function (i, val) {
freeDraw.createPolygon(val);
});
@ -34,9 +39,6 @@ function initCarto() {
map.setView(new L.LatLng(position.lat, position.lon), 5);
add_event_freeDraw();
if (qp_active())
display_qp(JSON.parse($("#quartier_prioritaires").val()));
}
function default_position (){
@ -81,6 +83,7 @@ function get_position() {
async: false
}).done(function (data) {
position = data
position.zoom = default_position().zoom
});
return position;

View file

@ -26,10 +26,12 @@
- if @facade.dossier.procedure.module_api_carto.use_api_carto
.col-lg-6.col-md-6
#map.mini{class: @facade.dossier.class_qp_active}
#map.mini{class: @facade.dossier.procedure.module_api_carto.classes}
%input{id: 'json_latlngs', type:'hidden', value: "#{@facade.dossier.json_latlngs}"}
%input{id: 'quartier_prioritaires', type:'hidden', value: "#{@facade.dossier.quartier_prioritaires.to_json}"}
%input{id: 'cadastres', type:'hidden', value: "#{@facade.dossier.cadastres.to_json}"}
%script{type: 'text/javascript'}
= "var dossier_id =#{@facade.dossier.id}"
initCarto();

View file

@ -29,6 +29,7 @@
%br
%input{type: 'hidden', value: "#{@dossier.json_latlngs}", name: 'json_latlngs', id: 'json_latlngs'}
%input{id: 'quartier_prioritaires', type:'hidden', value: "#{@dossier.quartier_prioritaires.to_json}"}
%input{id: 'cadastres', type:'hidden', value: "#{@dossier.cadastres.to_json}"}
-if @dossier.draft?
=render partial: '/layouts/etape_suivante'