add api_carto on back office and recapitulative page
This commit is contained in:
parent
ce6af625d2
commit
61b126b0f9
8 changed files with 74 additions and 27 deletions
|
@ -3,41 +3,52 @@ function initCarto() {
|
|||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
});
|
||||
|
||||
position = 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: 13,
|
||||
zoom: position.zoom,
|
||||
layers: [OSM]
|
||||
});
|
||||
|
||||
var freeDraw = new L.FreeDraw({
|
||||
mode: L.FreeDraw.MODES.CREATE
|
||||
//mode: L.FreeDraw.MODES.CREATE
|
||||
});
|
||||
|
||||
map.addLayer(freeDraw);
|
||||
|
||||
$.each($.parseJSON($("#json_latlngs").val()), function(i, val){
|
||||
freeDraw.createPolygon(val);
|
||||
});
|
||||
if ($("#json_latlngs").val() != '' && $("#json_latlngs").val() != '[]') {
|
||||
$.each($.parseJSON($("#json_latlngs").val()), function (i, val) {
|
||||
freeDraw.createPolygon(val);
|
||||
});
|
||||
map.setView(freeDraw.polygons[0].getBounds().getCenter(), position.zoom);
|
||||
}
|
||||
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){
|
||||
function add_event_freeDraw(freeDraw) {
|
||||
freeDraw.on('markers', function (e) {
|
||||
$("#json_latlngs").val(JSON.stringify(e.latLngs));
|
||||
});
|
||||
|
||||
$("#new").on('click', function (e){
|
||||
$("#new").on('click', function (e) {
|
||||
freeDraw.setMode(L.FreeDraw.MODES.CREATE);
|
||||
});
|
||||
|
||||
$("#edit").on('click', function (e){
|
||||
$("#edit").on('click', function (e) {
|
||||
freeDraw.setMode(L.FreeDraw.MODES.EDIT);
|
||||
});
|
||||
|
||||
$("#delete").on('click', function (e){
|
||||
$("#delete").on('click', function (e) {
|
||||
freeDraw.setMode(L.FreeDraw.MODES.DELETE);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,14 @@ table {
|
|||
font-size: 13;
|
||||
}
|
||||
|
||||
#map{
|
||||
height:600px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#map.mini{
|
||||
height:300px;
|
||||
}
|
||||
|
||||
#map section.overlay {
|
||||
position: absolute;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue