Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
426 righe
12 KiB
426 righe
12 KiB
2 anni fa
|
function _displayMapUpdatePolygon (divtarget) {
|
||
|
divtarget = typeof divtarget !== 'undefined' ? divtarget : 'app';
|
||
|
document.getElementById(divtarget).innerHTML = "<div id='map' class='map-wrapper'></div>";
|
||
|
document.getElementById('home').className = "nav-link flat";
|
||
|
document.getElementById('leaflet_crud_create').className = "nav-link flat";
|
||
|
document.getElementById('leaflet_crud_read').className = "nav-link flat";
|
||
|
document.getElementById('navbarDropdownUpdate').className = "nav-link dropdown-toggle active";
|
||
|
document.getElementById('leaflet_crud_delete').className = "nav-link flat";
|
||
|
|
||
|
var map, isCollapsed, openStreetMaps;
|
||
|
if (document.body.clientWidth <= 767) {
|
||
|
isCollapsed = true;
|
||
|
} else {
|
||
|
isCollapsed = false;
|
||
|
}
|
||
|
|
||
|
var promisePolygon = $.ajax({ url: "assets/dataservice/read_polygon.php",
|
||
|
method: "GET",
|
||
|
dataType: "json",
|
||
|
data: {command:"POLYGON"},
|
||
|
username: null,
|
||
|
password: null
|
||
|
});
|
||
|
|
||
|
var polygonObjects = L.geoJson(null, {
|
||
|
onEachFeature: function (feature, layer) {
|
||
|
if (feature.properties) {
|
||
|
layer.on({
|
||
|
click: function (e) {
|
||
|
var objectGIDToEdit = feature.properties.id;
|
||
|
$("#editobjectgid").val(objectGIDToEdit);
|
||
|
map.off();
|
||
|
map.remove();
|
||
|
_displayMapEditPolygon('app',objectGIDToEdit);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
promisePolygon.then(function (data) {
|
||
|
polygonObjects.addData(data);
|
||
|
map.addLayer(polygonObjects);
|
||
|
});
|
||
|
|
||
|
var url = "https://test-paesaggistica.lavoripubblici.sicilia.it/geoserver/mappers/wms";
|
||
|
|
||
|
//################# INIZIO PARTICELLA SELEZIONATA #################
|
||
|
<?php if ( strlen($_SESSION['SELECT_PARTICELLA']) > 100 ) { ?>
|
||
|
particella = L.geoJson(<?php echo $_SESSION['SELECT_PARTICELLA'];?>, {
|
||
|
style: {'color': "#ff0000",'fillColor': "rgb(255, 255, 0)",'fillOpacity': 0.4,'dashArray': 4,'weight': 3,'opacity': 0.9}
|
||
|
});
|
||
|
<?php } ?>
|
||
|
//################# FINE PARTICELLA SELEZIONATA #################
|
||
|
|
||
|
odm1 = L.tileLayer ('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||
|
maxZoom: 20,
|
||
|
minZoom: 1,
|
||
|
transparent: true,
|
||
|
attribution: 'OpenStreetMap | contributors CC-BY-SA.'
|
||
|
});
|
||
|
|
||
|
|
||
|
odm2 = L.tileLayer ('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
||
|
maxZoom: 20,
|
||
|
minZoom: 1,
|
||
|
transparent: true,
|
||
|
attribution: '© Esri | Source: Esri, USDA, USGS, AEX, GeoEye and the GIS User Community'
|
||
|
});
|
||
|
|
||
|
|
||
|
odm3 = L.tileLayer.wms (url, {
|
||
|
maxZoom: 20,
|
||
|
minZoom: 5,
|
||
|
transparent: true,
|
||
|
layers: 'mappers:provincie',
|
||
|
attribution: '© mapcloud services'
|
||
|
});
|
||
|
|
||
|
ctr10k = L.tileLayer.wms ('http://geoportal.mapcloud.it:8080/geoserver/wms', {
|
||
|
format: 'image/png',
|
||
|
transparent: true,
|
||
|
maxZoom: 20,
|
||
|
minZoom: 5,
|
||
|
transparent: true,
|
||
|
layers: 'mapcloud:ctr10k',
|
||
|
attribution: 'Carta Tecnica Regionale 1:10.000 - Regione Sicilia (Servizio WMS)'
|
||
|
});
|
||
|
|
||
|
|
||
|
particelle = L.tileLayer.wms(url, {
|
||
|
layers: "mappers:particelle_<?php echo $_SESSION['COMUNE_BELF']; ?>",
|
||
|
format: "image/png",
|
||
|
maxZoom: 20,
|
||
|
minZoom: 10,
|
||
|
transparent: true,
|
||
|
attribution: '© mapcloud services'
|
||
|
}),
|
||
|
|
||
|
|
||
|
map = L.map("map", {
|
||
|
zoom: <?php echo $_SESSION['ZOOM'];?>,
|
||
|
center: [<?php echo $_SESSION['CENTER'];?>],
|
||
|
layers: [odm1,particella],
|
||
|
minZoom: 3,
|
||
|
maxZoom: 20,
|
||
|
zoomControl: false,
|
||
|
attributionControl: false
|
||
|
});
|
||
|
|
||
|
map.setMaxBounds([<?php echo $_SESSION['BOUND']; ?>]);
|
||
|
|
||
|
var zoomControl = L.control.zoom({
|
||
|
position: "topleft"
|
||
|
}).addTo(map);
|
||
|
|
||
|
|
||
|
var baseLayers = [
|
||
|
{label: '<b>Opendata Map</b>', noShow: false, children: [
|
||
|
{label: 'OpenStreetMap', layer: odm1},
|
||
|
{label: 'Satellite Image', layer: odm2},
|
||
|
{label: 'Limiti provinciali', layer: odm3},
|
||
|
]},
|
||
|
{label: '<b>Cartografia Regionale</b>', children: [
|
||
|
{label: 'CTR 10K - volo 2012-2013', layer: ctr10k },
|
||
|
]},
|
||
|
];
|
||
|
|
||
|
var overlayLayers =
|
||
|
{
|
||
|
label: '<b>CARTOGRAFICI</b>',
|
||
|
noShow: true,
|
||
|
children: [
|
||
|
{label: '<b>Catasto</b>', children: [
|
||
|
{label: 'Particelle catastali', layer: particelle},
|
||
|
]},
|
||
|
{label: '<b>Particelle progetto</b>', children: [
|
||
|
{label: 'Particelle selezionate', layer: particella},
|
||
|
]},
|
||
|
]
|
||
|
};
|
||
|
|
||
|
var options = {
|
||
|
collapsed: true,
|
||
|
closedSymbol: '<i class="fal fa-plus-square" style="margin-right:5px"></i>',
|
||
|
openedSymbol: '<i class="fal fa-minus-square" style="margin-right:5px"></i>',
|
||
|
namedToggle: false,
|
||
|
spaceSymbol: ' ',
|
||
|
selectorBack: false,
|
||
|
collapseAll: '',
|
||
|
expandAll: '',
|
||
|
};
|
||
|
|
||
|
var layerControlTree = L.control.layers.tree(baseLayers, overlayLayers, options).addTo(map);
|
||
|
}
|
||
|
|
||
|
/* ============================================= */
|
||
|
|
||
|
function _displayMapEditPolygon (divtarget,objectgid) {
|
||
|
divtarget = typeof divtarget !== 'undefined' ? divtarget : 'app';
|
||
|
document.getElementById(divtarget).innerHTML = "<div id='map' class='map-wrapper'></div>";
|
||
|
|
||
|
var map, isCollapsed, openStreetMaps;
|
||
|
if (document.body.clientWidth <= 767) {
|
||
|
isCollapsed = true;
|
||
|
} else {
|
||
|
isCollapsed = false;
|
||
|
}
|
||
|
|
||
|
var url = "https://test-paesaggistica.lavoripubblici.sicilia.it/geoserver/mappers/wms";
|
||
|
|
||
|
//################# INIZIO PARTICELLA SELEZIONATA #################
|
||
|
<?php if ( strlen($_SESSION['SELECT_PARTICELLA']) > 100 ) { ?>
|
||
|
particella = L.geoJson(<?php echo $_SESSION['SELECT_PARTICELLA'];?>, {
|
||
|
style: {'color': "#ff0000",'fillColor': "rgb(255, 255, 0)",'fillOpacity': 0.4,'dashArray': 4,'weight': 3,'opacity': 0.9}
|
||
|
});
|
||
|
<?php } ?>
|
||
|
//################# FINE PARTICELLA SELEZIONATA #################
|
||
|
|
||
|
odm1 = L.tileLayer ('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||
|
maxZoom: 20,
|
||
|
minZoom: 1,
|
||
|
transparent: true,
|
||
|
attribution: 'OpenStreetMap | contributors CC-BY-SA.'
|
||
|
});
|
||
|
|
||
|
|
||
|
odm2 = L.tileLayer ('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
||
|
maxZoom: 20,
|
||
|
minZoom: 1,
|
||
|
transparent: true,
|
||
|
attribution: '© Esri | Source: Esri, USDA, USGS, AEX, GeoEye and the GIS User Community'
|
||
|
});
|
||
|
|
||
|
|
||
|
odm3 = L.tileLayer.wms (url, {
|
||
|
maxZoom: 20,
|
||
|
minZoom: 5,
|
||
|
transparent: true,
|
||
|
layers: 'mappers:provincie',
|
||
|
attribution: '© mapcloud services'
|
||
|
});
|
||
|
|
||
|
ctr10k = L.tileLayer.wms ('http://geoportal.mapcloud.it:8080/geoserver/wms', {
|
||
|
format: 'image/png',
|
||
|
transparent: true,
|
||
|
maxZoom: 20,
|
||
|
minZoom: 5,
|
||
|
transparent: true,
|
||
|
layers: 'mapcloud:ctr10k',
|
||
|
attribution: 'Carta Tecnica Regionale 1:10.000 - Regione Sicilia (Servizio WMS)'
|
||
|
});
|
||
|
|
||
|
|
||
|
particelle = L.tileLayer.wms(url, {
|
||
|
layers: "mappers:particelle_<?php echo $_SESSION['COMUNE_BELF']; ?>",
|
||
|
format: "image/png",
|
||
|
maxZoom: 20,
|
||
|
minZoom: 10,
|
||
|
transparent: true,
|
||
|
attribution: '© mapcloud services'
|
||
|
}),
|
||
|
|
||
|
|
||
|
map = L.map("map", {
|
||
|
zoom: <?php echo $_SESSION['ZOOM'];?>,
|
||
|
center: [<?php echo $_SESSION['CENTER'];?>],
|
||
|
layers: [odm1,particella],
|
||
|
minZoom: 3,
|
||
|
maxZoom: 20,
|
||
|
zoomControl: false,
|
||
|
attributionControl: false
|
||
|
});
|
||
|
|
||
|
map.setMaxBounds([<?php echo $_SESSION['BOUND']; ?>]);
|
||
|
|
||
|
var zoomControl = L.control.zoom({
|
||
|
position: "topleft"
|
||
|
}).addTo(map);
|
||
|
|
||
|
|
||
|
var baseLayers = [
|
||
|
{label: '<b>Opendata Map</b>', noShow: false, children: [
|
||
|
{label: 'OpenStreetMap', layer: odm1},
|
||
|
{label: 'Satellite Image', layer: odm2},
|
||
|
{label: 'Limiti provinciali', layer: odm3},
|
||
|
]},
|
||
|
{label: '<b>Cartografia Regionale</b>', children: [
|
||
|
{label: 'CTR 10K - volo 2012-2013', layer: ctr10k },
|
||
|
]},
|
||
|
];
|
||
|
|
||
|
var overlayLayers =
|
||
|
{
|
||
|
label: '<b>CARTOGRAFICI</b>',
|
||
|
noShow: true,
|
||
|
children: [
|
||
|
{label: '<b>Catasto</b>', children: [
|
||
|
{label: 'Particelle catastali', layer: particelle},
|
||
|
]},
|
||
|
{label: '<b>Particelle progetto</b>', children: [
|
||
|
{label: 'Particelle selezionate', layer: particella},
|
||
|
]},
|
||
|
]
|
||
|
};
|
||
|
|
||
|
var options = {
|
||
|
collapsed: true,
|
||
|
closedSymbol: '<i class="fal fa-plus-square" style="margin-right:5px"></i>',
|
||
|
openedSymbol: '<i class="fal fa-minus-square" style="margin-right:5px"></i>',
|
||
|
namedToggle: false,
|
||
|
spaceSymbol: ' ',
|
||
|
selectorBack: false,
|
||
|
collapseAll: '',
|
||
|
expandAll: '',
|
||
|
};
|
||
|
|
||
|
var layerControlTree = L.control.layers.tree(baseLayers, overlayLayers, options).addTo(map);
|
||
|
|
||
|
/* Digitize Function */
|
||
|
var drawnItems = new L.FeatureGroup();
|
||
|
map.addLayer(drawnItems);
|
||
|
|
||
|
var promiseObjectEdit = $.ajax({ url: "assets/dataservice/read_one_polygon.php",
|
||
|
method: "GET",
|
||
|
dataType: "json",
|
||
|
data: {command:"POLYGON",id:objectgid},
|
||
|
username: null,
|
||
|
password: null
|
||
|
});
|
||
|
|
||
|
promiseObjectEdit.then(function (data) {
|
||
|
L.geoJson(data, {
|
||
|
style: function (feature) {
|
||
|
return {
|
||
|
color: "#FF0000"
|
||
|
};
|
||
|
},
|
||
|
onEachFeature: _onEachFeature
|
||
|
});
|
||
|
});
|
||
|
|
||
|
var drawControl = new L.Control.Draw({
|
||
|
draw: {
|
||
|
position: 'topleft',
|
||
|
polyline: false,
|
||
|
polygon: false,
|
||
|
rectangle: false,
|
||
|
circle: false,
|
||
|
marker: false,
|
||
|
circlemarker: false
|
||
|
},
|
||
|
edit: {
|
||
|
featureGroup: drawnItems,
|
||
|
edit: true,
|
||
|
remove: false
|
||
|
}
|
||
|
});
|
||
|
|
||
|
map.addControl(drawControl);
|
||
|
|
||
|
/* edit functions */
|
||
|
map.on('draw:edited', function (e) {
|
||
|
var layers = e.layers;
|
||
|
layers.eachLayer(function(layer) {
|
||
|
var drawnJSONObject = layer.toGeoJSON();
|
||
|
var objectGeometry = Terraformer.WKT.convert(drawnJSONObject.geometry);
|
||
|
var objectGIDToEdit = $("#editobjectgid").val();
|
||
|
$.ajax({ url: "assets/dataservice/update_polygon.php",
|
||
|
method: "GET",
|
||
|
dataType: "json",
|
||
|
data: {command:"UPDATE",id:objectGIDToEdit,geometry:objectGeometry},
|
||
|
success: function (data) {
|
||
|
if (data.response == "200") {
|
||
|
map.off();
|
||
|
map.remove();
|
||
|
_displayMapRead('app');
|
||
|
} else {
|
||
|
map.off();
|
||
|
map.remove();
|
||
|
_displayMapRead('app');
|
||
|
console.log('Update feature failed.');
|
||
|
}
|
||
|
},
|
||
|
username: null,
|
||
|
password: null
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function _onEachFeature (feature, layer) {
|
||
|
drawnItems.addLayer(layer);
|
||
|
map.fitBounds(drawnItems.getBounds());
|
||
|
if (feature.properties) {
|
||
|
layer.on({
|
||
|
click: function (e) {
|
||
|
var notes = feature.properties.notes;
|
||
|
_buildDigitiseModalBox('modalform','UPDATE POLYGON',notes);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function _buildDigitiseModalBox (targetmodal,context,notes) {
|
||
|
targetmodal = typeof targetmodal !== 'undefined' ? targetmodal : 'modalbox';
|
||
|
context = typeof context !== 'undefined' ? context : 'UPDATE POLYGON';
|
||
|
notes = typeof notes !== 'undefined' ? notes : '';
|
||
|
|
||
|
var htmlformcomponent = "" +
|
||
|
"<input type='hidden' id='command' name='command' value='"+context+"'/>" +
|
||
|
"<table id='feature_data' class='table table-condensed table-bordered table-striped'>" +
|
||
|
"<thead>" +
|
||
|
"<tr>" +
|
||
|
"<th colspan='2' class='text-center'>Feature Data</th>" +
|
||
|
"</tr>" +
|
||
|
"</thead>" +
|
||
|
"<tbody>" +
|
||
|
"<tr>" +
|
||
|
"<td class=''>Notes</td>" +
|
||
|
"<td class='text-center'><input type='text' id='notes' name='notes' class='form-control' value='"+notes+"'/></td>" +
|
||
|
"</tr>" +
|
||
|
"</tbody>" +
|
||
|
"</table>" +
|
||
|
"";
|
||
|
var modalfooter = "" +
|
||
|
"<button type='button' id='canceldigitize' class='btn btn-default' data-dismiss='modal'><i class='fa fa-power-off'></i> Cancel</button>" +
|
||
|
"<button type='button' id='saveattributedata' class='btn btn-primary'><i class='fa fa-floppy-o'></i> Save</button>" +
|
||
|
"";
|
||
|
$("#form_modal_body").empty();
|
||
|
$("#form_modal_footer").empty().html(modalfooter);
|
||
|
$("#form_modal_body").removeClass().addClass('modal-body');
|
||
|
$("#form_modal_size").removeClass().addClass('modal-dialog');
|
||
|
$("#form_modal_body").html(htmlformcomponent);
|
||
|
$("#form_modal_label").html("<i class='fa fa-pencil'></i> "+context+"");
|
||
|
|
||
|
$('#'+targetmodal+'').modal({show:true, backdrop:'static', keyboard:false});
|
||
|
}
|
||
|
|
||
|
$("#modalform").on('shown.bs.modal', function(){
|
||
|
_activateFeatureSave();
|
||
|
});
|
||
|
|
||
|
function _activateFeatureSave () {
|
||
|
$("#saveattributedata").on('click', function(evt){
|
||
|
evt.stopImmediatePropagation();
|
||
|
var gid = $("#editobjectgid").val();
|
||
|
var noteString = $('#notes').val();
|
||
|
$.ajax({ url: "assets/dataservice/update_data_polygon.php",
|
||
|
method: "GET",
|
||
|
dataType: "json",
|
||
|
data: {id:gid, command:"UPDATE", notes:noteString},
|
||
|
success: function (data) {
|
||
|
if (data.response=="200") {
|
||
|
$("#modalform").modal('hide');
|
||
|
_displayMapRead('app');
|
||
|
} else {
|
||
|
$("#modalform").modal('hide');
|
||
|
console.log('Failed to save.');
|
||
|
}
|
||
|
},
|
||
|
username: null,
|
||
|
password: null
|
||
|
});
|
||
|
return false;
|
||
|
});
|
||
|
}
|
||
|
}
|