Add map for gestionnaire
This commit is contained in:
parent
bdaa51c5cc
commit
373d9999fc
12 changed files with 766 additions and 0 deletions
10
app/assets/javascripts/new_design/carte/cadastre.js
Normal file
10
app/assets/javascripts/new_design/carte/cadastre.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
function drawCadastre (map) {
|
||||
drawLayerWithItems(map, dossierCadastres, {
|
||||
fillColor: '#8A6D3B',
|
||||
weight: 2,
|
||||
opacity: 0.7,
|
||||
color: '#8A6D3B',
|
||||
dashArray: '3',
|
||||
fillOpacity: 0.5
|
||||
});
|
||||
}
|
59
app/assets/javascripts/new_design/carte/carte.js
Normal file
59
app/assets/javascripts/new_design/carte/carte.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
function initCarto() {
|
||||
if ($("#map").length > 0) {
|
||||
var position = getPosition() || defaultGestionnairePosition();
|
||||
|
||||
var map = L.map('map', {
|
||||
scrollWheelZoom: false
|
||||
}).setView([position.lat, position.lon], position.zoom);
|
||||
|
||||
L.tileLayer('http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
// draw external polygons
|
||||
drawCadastre(map);
|
||||
drawQuartiersPrioritaires(map);
|
||||
|
||||
// draw user polygon
|
||||
drawUserSelection(map);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('turbolinks:load', initCarto);
|
||||
|
||||
function drawUserSelection(map) {
|
||||
var polygon = L.polygon(dossierJsonLatLngs, { color: 'red', zIndex: 3 }).addTo(map);
|
||||
map.fitBounds(polygon.getBounds());
|
||||
}
|
||||
|
||||
function defaultGestionnairePosition() {
|
||||
var LON = '2.428462';
|
||||
var LAT = '46.538192';
|
||||
return { lon: LON, lat: LAT, zoom: 5 }
|
||||
}
|
||||
|
||||
function getPosition() {
|
||||
var position;
|
||||
|
||||
$.ajax({
|
||||
url: getPositionUrl,
|
||||
dataType: 'json',
|
||||
async: false
|
||||
}).done(function (data) {
|
||||
position = data
|
||||
});
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
function drawLayerWithItems(map, items, style) {
|
||||
if (Array.isArray(items) && items.length > 0) {
|
||||
var layer = new L.GeoJSON();
|
||||
|
||||
items.forEach(function (item) {
|
||||
layer.addData(item.geometry);
|
||||
});
|
||||
|
||||
layer.setStyle(style).addTo(map);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
function drawQuartiersPrioritaires (map) {
|
||||
drawLayerWithItems(map, dossierQuartiersPrioritaires, {
|
||||
fillColor: '#31708F',
|
||||
weight: 2,
|
||||
opacity: 0.7,
|
||||
color: '#31708F',
|
||||
dashArray: '3',
|
||||
fillOpacity: 0.5
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue