/* UTILITY FUNCTIONS */ //function writeScale() { // var d = document.getElementById('info'); // d.innerHTML = this.getResolution(); //} function mergeStyle(style, base_style) { for(i in base_style) { var mode = base_style[i]; for(k in mode) { if(!style[i][k]) style[i][k] = mode[k]; } } return new OpenLayers.StyleMap(style); } /* GLOBAL OPTIONS */ OpenLayers.Console.error = function(txt) { alert(txt); } OpenLayers.Events.prototype.includeXY = true; OpenLayers.Util.onImageLoadError = function() { this.src = "img/empty.png"; } var map = null; var format = null; var wkt = null; var baseLayers = null; var layers = new Object; var edit; var edit_select; var selectControl; var highlightCtrl; var current_rischio; var proposte_loaded = false; //Ugly hack. var rischi = { names: { r_tot:'totale', r_antr:'antropico', r_disc:'discariche', r_estr: 'aree_estrattive', r_ferr: 'rete ferroviaria', r_frane: 'frane', r_ind: 'aree industriali', r_piene: 'piene', r_stab: 'stabilimenti', r_strade: 'rete_stradale' }, intervals: { r_tot: [187.89, 754.63, 1742.05], r_antr: [21.36,100.27,266.78], r_disc: [3,12,49], r_estr: [23.57,81.38,188.36], r_ferr: [48.00,184.27,494.46], r_frane: [33.79,139.45,463.71], r_ind: [21.82,81.38,188.36], r_piene: [15.69,53.58,156.10], r_stab: [4.15,16.43,32.79], r_strade: [122.00,520.12,1381.57] }, colors: ['#00cc33', '#dddd00', '#ff9900','#cc3300'] }; var controls = null; var popup = null; function init() { var options = { projection: new OpenLayers.Projection("EPSG:900913"), //displayProjection: new OpenLayers.Projection("EPSG:32632"), units: "m", maxResolution: 156543.0339, //maxResolution: 99.22366015624993, maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34) }; /* MAP CREATION AND CONTROLS */ map = new OpenLayers.Map('map', options); var panzoom = new OpenLayers.Control.PanZoomBar({slideFactor: 200}); panzoom.zoomWorldIcon = true; map.addControl(panzoom); map.removeControl (map.controls [1]); //Pannello di zoom e pan con stile personalizzato (olControlNavToolbar_aumi) //in maniera da inserire le icone custom OpenLayers.Control.CustomNavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, { /** * Constructor: OpenLayers.Control.NavToolbar * Add our two mousedefaults controls. * * Parameters: * options - {Object} An optional object whose properties will be used to extend the control. */ initialize: function(options) { OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]); this.addControls([ new OpenLayers.Control.Navigation({dblclick:false, active:true}), //Here it come new OpenLayers.Control.ZoomBox({alwaysZoom:true}), new OpenLayers.Control.Button({ displayClass: 'Print', type: OpenLayers.Control.TYPE_TOOL, eventListeners: { 'activate': function(){ //alert('Control of OpenLayers.Control.TYPE_TOGGLE type is activated') stampaMappaCorrente(); var navCtrls = map.getControlsByClass('OpenLayers.Control.Navigation'); for (var i = 0; i < navCtrls.length; i++) { navCtrls[i].activate(); } var navCtrls = map.getControlsByClass('OpenLayers.Control.Button'); for (var i = 0; i < navCtrls.length; i++) { navCtrls[i].deactivate(); } }, 'deactivate': function(){ //alert('Control of OpenLayers.Control.TYPE_TOGGLE type is deactivated') } } }) ]); // To make the custom navtoolbar use the regular navtoolbar style this.displayClass = 'olControlNavToolbar_aumi' }, /** * Method: draw * calls the default draw, and then activates mouse defaults. */ draw: function() { var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments); this.activateControl(this.controls[0]); return div; } } ); var panel = new OpenLayers.Control.CustomNavToolbar({position: new OpenLayers.Pixel(15,50)}); map.addControl(panel); //REMOVE ME [debug to visualize resolution //map.events.register('zoomend', map, writeScale); //map.addControl(new OpenLayers.Control.KeyboardDefaults()); //map.addControl(new OpenLayers.Control.LayerSwitcher()); var external_control = new OpenLayers.Control.MousePosition({ div: document.getElementById('location') }); map.addControl(external_control); var navCtrls = map.getControlsByClass('OpenLayers.Control.Navigation'); for (var i = 0; i < navCtrls.length; i++) { navCtrls[i].disableZoomWheel(); } //visualizza scala: var scaleControl = map.addControl(new OpenLayers.Control.Scale(null, { updateScale: function() { var scale = map.getScale(); //alert("scale=" + scale); if (scale) { document.getElementById('scale').innerHTML = "1 : " + OpenLayers.Number.format(Math.round(scale), 0, "."); } } })); //scalebar var scalebar = new OpenLayers.Control.ScaleBar({ div: document.getElementById("scalebar"), minWidth: 75, maxWidth: 175 }); map.addControl(scalebar); // OpenStreetMap var openstreetmap = new OpenLayers.Layer.OSM.Mapnik("OSM", {isBaseLayer:true, displayInLayerSwitcher:true, numZoomLevels: 20}); map.addLayer(openstreetmap); /* GOOGLE MAPS */ var gmap = new OpenLayers.Layer.Google( "Google Streets", {numZoomLevels: 20} ); var gphy = new OpenLayers.Layer.Google( "Google Physical", {type: google.maps.MapTypeId.TERRAIN} );//lo uso solo per "nessuna base" e per mantenere la scala. var ghyb = new OpenLayers.Layer.Google( "Google Hybrid", {type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20} ); var gsat = new OpenLayers.Layer.Google( "Google Satellite", {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 20} ); map.addLayers([gmap, ghyb, gsat, gphy]); ghyb.setVisibility(false); gsat.setVisibility(false); /* SITAP BASE CARTOGRAPHY */ var igm250000 = new OpenLayers.Layer.WMS( "igm 250000", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:CB.IGM250000', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(igm250000); igm250000.setVisibility(false); var igm100000 = new OpenLayers.Layer.WMS( "igm 100000", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:MB.IGM100000', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(igm100000); igm100000.setVisibility(false); var igm25000 = new OpenLayers.Layer.WMS( "igm 25000", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:CB.IGM25000', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(igm25000); igm25000.setVisibility(false); /* ************************************* WMS REGIONALI ************************************* */ // WMS Abruzzo CTR var abruzzo_ctr_wms = new OpenLayers.Layer.WMS( "sf:abruzzo_ctr", "http://2.42.228.54:8080/geoserver/sf/wms", { LAYERS: 'sf:abruzzo_ctr', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(abruzzo_ctr_wms); abruzzo_ctr_wms.setVisibility(false); // WMS Emilia Romagna var emiliaromagna_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:DBTR2013_Ctr5", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:DBTR2013_Ctr5', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(emiliaromagna_ctr_wms); emiliaromagna_ctr_wms.setVisibility(false); // WMS Lazio var lazio_ctr_wms = new OpenLayers.Layer.WMS( "hub:5000_Mosaico_CTR5K_EPSG3004.ecw", "http://2.42.228.54/geoserver/hub/wms", { LAYERS: 'hub:5000_Mosaico_CTR5K_EPSG3004.ecw', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(lazio_ctr_wms); lazio_ctr_wms.setVisibility(false); // WMS Liguria var liguria_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:C1237", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:C1237', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(liguria_ctr_wms); liguria_ctr_wms.setVisibility(false); // WMS Lombardia var lombardia_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:lombardia_ctr_10000", "http://2.42.228.54:8080/geoserver/sf/wms", { LAYERS: 'sf:lombardia_ctr_10000', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(lombardia_ctr_wms); lombardia_ctr_wms.setVisibility(false); // WMS Molise var molise_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:molise_ctr", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:molise_ctr', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(molise_ctr_wms); molise_ctr_wms.setVisibility(false); // WMS Piemonte var piemonte_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:piemonte_ctr", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:piemonte_ctr', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(piemonte_ctr_wms); piemonte_ctr_wms.setVisibility(false); // WMS Sicilia var sicilia_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:sicilia_ctr", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:sicilia_ctr', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(sicilia_ctr_wms); sicilia_ctr_wms.setVisibility(false); // WMS Toscana var toscana_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:toscana_ctr_10k", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:toscana_ctr_10k', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(toscana_ctr_wms); toscana_ctr_wms.setVisibility(false); // WMS Toscana var toscana_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:toscana_ctr_10k", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:toscana_ctr_10k', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(toscana_ctr_wms); toscana_ctr_wms.setVisibility(false); // WMS Umbria var umbria_ctr_wms = new OpenLayers.Layer.WMS( "apar_wms:0", "http://sitap.beniculturali.it:8080/geoserver/apar_wms/wms", { LAYERS: 'apar_wms:0', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(umbria_ctr_wms); umbria_ctr_wms.setVisibility(false); /* *** GESTIONE DEL MENU *** */ //WMS Abruzzo $('#abruzzo_ctr_wms').click(function() { abruzzo_ctr_wms.setVisibility(this.checked); }); $('#abruzzo_ctr_wms').attr('checked', false) //WMS Emilia Romagna $('#emiliaromagna_ctr_wms').click(function() { emiliaromagna_ctr_wms.setVisibility(this.checked); }); $('#emiliaromagna_ctr_wms').attr('checked', false) //WMS Lazio $('#lazio_ctr_wms').click(function() { lazio_ctr_wms.setVisibility(this.checked); }); $('#lazio_ctr_wms').attr('checked', false) //WMS Liguria $('#liguria_ctr_wms').click(function() { liguria_ctr_wms.setVisibility(this.checked); }); $('#liguria_ctr_wms').attr('checked', false) //WMS Lombradia $('#lombardia_ctr_wms').click(function() { lombardia_ctr_wms.setVisibility(this.checked); }); $('#lombardia_ctr_wms').attr('checked', false) //WMS Molise $('#molise_ctr_wms').click(function() { molise_ctr_wms.setVisibility(this.checked); }); $('#molise_ctr_wms').attr('checked', false) //WMS Piemonte $('#piemonte_ctr_wms').click(function() { piemonte_ctr_wms.setVisibility(this.checked); }); $('#piemonte_ctr_wms').attr('checked', false) //WMS Sicilia $('#sicilia_ctr_wms').click(function() { sicilia_ctr_wms.setVisibility(this.checked); }); $('#sicilia_ctr_wms').attr('checked', false) //WMS Toscana $('#toscana_ctr_wms').click(function() { toscana_ctr_wms.setVisibility(this.checked); }); $('#toscana_ctr_wms').attr('checked', false) //WMS Umbria $('#umbria_ctr_wms').click(function() { umbria_ctr_wms.setVisibility(this.checked); }); $('#umbria_ctr_wms').attr('checked', false) /* ************************************* FINE WMS REGIONALI ************************************* */ var layer_20121012121219_SfondoCartRif = new OpenLayers.Layer.WMS( " Piemonte - Carto Base", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:SfondoCartRif', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20121012121219_SfondoCartRif); layer_20121012121219_SfondoCartRif.setVisibility(false);$('#layer_20121012121219_SfondoCartRif').click(function() { layer_20121012121219_SfondoCartRif.setVisibility(this.checked); });$('#layer_20121012121219_SfondoCartRif').attr('checked', false); var layer_20121012145335_0 = new OpenLayers.Layer.WMS( " Emilia Romagna - Liv.0", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:0', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20121012145335_0); layer_20121012145335_0.setVisibility(false);$('#layer_20121012145335_0').click(function() { layer_20121012145335_0.setVisibility(this.checked); });$('#layer_20121012145335_0').attr('checked', false); var layer_20121012150812_2 = new OpenLayers.Layer.WMS( " Emilia Romagna - Liv.2", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:2', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20121012150812_2); layer_20121012150812_2.setVisibility(false);$('#layer_20121012150812_2').click(function() { layer_20121012150812_2.setVisibility(this.checked); });$('#layer_20121012150812_2').attr('checked', false); var layer_20121012151714_1 = new OpenLayers.Layer.WMS( " Emilia Romagna - Liv.1", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:1', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20121012151714_1); layer_20121012151714_1.setVisibility(false);$('#layer_20121012151714_1').click(function() { layer_20121012151714_1.setVisibility(this.checked); });$('#layer_20121012151714_1').attr('checked', false); var layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_2 = new OpenLayers.Layer.WMS( " LAZIO PTPR A - Paesaggi", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Lazio_PTPR_A_2', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_2); layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_2.setVisibility(false);$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_2').click(function() { layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_2.setVisibility(this.checked); });$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_2').attr('checked', false); var layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_3 = new OpenLayers.Layer.WMS( " LAZIO PTPR A - Rispetto", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Lazio_PTPR_A_3', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_3); layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_3.setVisibility(false);$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_3').click(function() { layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_3.setVisibility(this.checked); });$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_3').attr('checked', false); var layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_4 = new OpenLayers.Layer.WMS( " LAZIO PTPR A - Proposte", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Lazio_PTPR_A_4', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_4); layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_4.setVisibility(false);$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_4').click(function() { layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_4.setVisibility(this.checked); });$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_4').attr('checked', false); var layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_5 = new OpenLayers.Layer.WMS( " LAZIO PTPR A - CTR", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Lazio_PTPR_A_5', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_5); layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_5.setVisibility(false);$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_5').click(function() { layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_5.setVisibility(this.checked); });$('#layer_Lazio_PTPR_Tav_A_Lazio_PTPR_A_5').attr('checked', false); var layer_Piemonte_Aree_Vincolate_VincoloIdrogeologicoPl = new OpenLayers.Layer.WMS( " PIEMONTE - Vincolo IdroGeol.", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:VincoloIdrogeologicoPl', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Piemonte_Aree_Vincolate_VincoloIdrogeologicoPl); layer_Piemonte_Aree_Vincolate_VincoloIdrogeologicoPl.setVisibility(false);$('#layer_Piemonte_Aree_Vincolate_VincoloIdrogeologicoPl').click(function() { layer_Piemonte_Aree_Vincolate_VincoloIdrogeologicoPl.setVisibility(this.checked); });$('#layer_Piemonte_Aree_Vincolate_VincoloIdrogeologicoPl').attr('checked', false); var layer_Piemonte_Aree_Vincolate_Galassini = new OpenLayers.Layer.WMS( " PIEMONTE - Galassini", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Galassini', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Piemonte_Aree_Vincolate_Galassini); layer_Piemonte_Aree_Vincolate_Galassini.setVisibility(false);$('#layer_Piemonte_Aree_Vincolate_Galassini').click(function() { layer_Piemonte_Aree_Vincolate_Galassini.setVisibility(this.checked); });$('#layer_Piemonte_Aree_Vincolate_Galassini').attr('checked', false); var layer_Piemonte_Aree_Vincolate_Vincoli = new OpenLayers.Layer.WMS( " PIEMONTE - Vincoli", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Vincoli', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Piemonte_Aree_Vincolate_Vincoli); layer_Piemonte_Aree_Vincolate_Vincoli.setVisibility(false);$('#layer_Piemonte_Aree_Vincolate_Vincoli').click(function() { layer_Piemonte_Aree_Vincolate_Vincoli.setVisibility(this.checked); });$('#layer_Piemonte_Aree_Vincolate_Vincoli').attr('checked', false); var layer_Piemonte_Aree_Vincolate_Vincoli1089 = new OpenLayers.Layer.WMS( " PIEMONTE - V.1089", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Vincoli1089', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Piemonte_Aree_Vincolate_Vincoli1089); layer_Piemonte_Aree_Vincolate_Vincoli1089.setVisibility(false);$('#layer_Piemonte_Aree_Vincolate_Vincoli1089').click(function() { layer_Piemonte_Aree_Vincolate_Vincoli1089.setVisibility(this.checked); });$('#layer_Piemonte_Aree_Vincolate_Vincoli1089').attr('checked', false); var layer_Piemonte_Aree_Vincolate_Vincoli1497 = new OpenLayers.Layer.WMS( " PIEMONTE - V.1497", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:Vincoli1497', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_Piemonte_Aree_Vincolate_Vincoli1497); layer_Piemonte_Aree_Vincolate_Vincoli1497.setVisibility(false);$('#layer_Piemonte_Aree_Vincolate_Vincoli1497').click(function() { layer_Piemonte_Aree_Vincolate_Vincoli1497.setVisibility(this.checked); });$('#layer_Piemonte_Aree_Vincolate_Vincoli1497').attr('checked', false); var layer_20140414224040_55 = new OpenLayers.Layer.WMS( " PUGLIA PPTR-AMBITI", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:55', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20140414224040_55); layer_20140414224040_55.setVisibility(false);$('#layer_20140414224040_55').click(function() { layer_20140414224040_55.setVisibility(this.checked); });$('#layer_20140414224040_55').attr('checked', false); var layer_20140415114506_20 = new OpenLayers.Layer.WMS( " PugliaPPTR-BP-NotIntPub", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:20', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20140415114506_20); layer_20140415114506_20.setVisibility(false);$('#layer_20140415114506_20').click(function() { layer_20140415114506_20.setVisibility(this.checked); });$('#layer_20140415114506_20').attr('checked', false); var layer_20140915091449_BeniPaesaggistici = new OpenLayers.Layer.WMS( " Beni paesaggistici Comune Torino", "http://sitap.beniculturali.it:8080/geoserver/test_ws/wms", { layers: 'test_ws:BeniPaesaggistici', transparent: 'true'},{ ratio: 1, displayOutsideMaxExtent: true} ); map.addLayer(layer_20140915091449_BeniPaesaggistici); layer_20140915091449_BeniPaesaggistici.setVisibility(false);$('#layer_20140915091449_BeniPaesaggistici').click(function() { layer_20140915091449_BeniPaesaggistici.setVisibility(this.checked); });$('#layer_20140915091449_BeniPaesaggistici').attr('checked', false); /* var igm_wms = new OpenLayers.Layer.Image("No base layer", 'img/white.png', map.maxExtent, new OpenLayers.Size(1, 1), { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: true } ); map.addLayer(igm_wms); igm_wms.setVisibility(false); */ /* SITAP BASE CARTOGRAPHY */ var sitap = new OpenLayers.Layer.TileCache("Sitap", "cache", 'italia', {format: 'image/png', transparent: 'true'}); sitap.addOptions({isBaseLayer: false}); //senza questa opzione, sitap diventa in automatico un layer di base map.addLayer(sitap); sitap.setVisibility(false); var igm = new OpenLayers.Layer.TileCache("Mappe IGM", "cache", 'igm', {format: 'image/png', transparent: 'false'}); map.addLayer(igm); igm.setVisibility(false); var igm_storici = new OpenLayers.Layer.WMS( "igm storici -", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:igm_regioni_2', STYLES: '', format: 'image/png', transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, isBaseLayer: false, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(igm_storici); igm_storici.setVisibility(false); baseLayers = [openstreetmap, gmap, ghyb, gsat, igm25000, igm100000, igm250000, igm]; map.setCenter(new OpenLayers.LonLat(1200000, 5400000, 0), 5); format = new OpenLayers.Format.GeoJSON({ 'internalProjection': map.baseLayer.projection, 'externalProjection': map.baseLayer.projection }); wkt = new OpenLayers.Format.WKT({ 'internalProjection': map.baseLayer.projection, 'externalProjection': map.baseLayer.projection }); var base_style = { 'default': { fillColor: "#ddcc00", strokeColor: "#aaaa00", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 }, 'temporary': { fillColor: "#fff79d", strokeColor: "#aaaa00", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 }, 'select': { fillColor: "#fff79d", strokeColor: "#aaaa00", strokeWidth:activateLayer, pointRadius: 4, fillOpacity: 0.5 } }; var style = base_style; addLayer('vincoli', 'Vincoli 1497', 'geometry/1497/', mergeStyle(style, base_style)); /*mostriamo anche il layer wms ma solo fino ad una certa scala*/ var v1497_shp_wms = new OpenLayers.Layer.WMS( "v1497_wgs84", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar.public:v1497_wgs84', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(v1497_shp_wms); v1497_shp_wms.setVisibility(false); //evento per l'interrogazione sul layer WMS così da gestire la successiva interrogazione (info) della feature selezionata if (1>0) { map.events.register("click", map, getVincolo); map.events.register("zoomend", map, mostraLayersByZoom); } //set up a save strategy var saveStrategy = new OpenLayers.Strategy.Save(); saveStrategy.events.register("success", '', showSuccessMsg); saveStrategy.events.register("failure", '', showFailureMsg); var WGS84_UTM32N = new OpenLayers.Projection("EPSG:32632"); // WGS84 Google Mercator projection var WGS84_google_mercator = new OpenLayers.Projection("EPSG:900913"); // map extent //var mapextent = new OpenLayers.Bounds(-297307, 4205608, 4122179, 6436347).transform(WGS84_UTM32N, WGS84_google_mercator); //var mapextent = new OpenLayers.Bounds(1440719, 5436756, 1453902, 5445136).transform(WGS84_UTM32N, WGS84_google_mercator); var mapextent = new OpenLayers.Bounds(445169, 4214431, 3037913, 6366898).transform(WGS84_UTM32N, WGS84_google_mercator); //var mapextent = new OpenLayers.Bounds(12.8, 43.7, 13.0, 43.9).transform(WGS84, WGS84_google_mercator); //WGS84 //wfs-t editable overlay var v1497_shp = new OpenLayers.Layer.Vector("v1497_shp", { strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy], //projection: new OpenLayers.Projection("EPSG:26910"), protocol: new OpenLayers.Protocol.WFS({ version: "1.1.0", // loading data through sitap.beniculturali.it url path url: "http://sitap.beniculturali.it:8080/geoserver/wfs", featureNS : "http://www.opengeospatial.net/cite", maxExtent: mapextent, // layer name featureType: "v1497pol_wgs84", // geometry column name geometryName: "the_geom", schema: "http://sitap.beniculturali.it:8080/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=cite:v1497pol_wgs84" }) }); map.addLayer(v1497_shp); v1497_shp.setVisibility(false); map.zoomToExtent(mapextent); /* highlight sul mouseover*/ // NB: highlight serve solo per dare l'effetto mouseover al layer v1497 var highlight = new OpenLayers.Control.SelectFeature(v1497_shp, { hover: true, highlightOnly: true, renderIntent: "temporary" }); map.addControl(highlight); highlight.activate(); $('#v1497_shp').click(function() { if (this.checked) { v1497_shp_wms.setVisibility(this.checked); } else { v1497_shp_wms.setVisibility(this.checked); edit_select.removeAllFeatures(); clearInfo(); } }); $('#v1497_shp').attr('checked', false) /***** anomalie ****/ var v1497_CodvrNoCodvin = new OpenLayers.Layer.WMS( "v1497_CodvrNoCodvin", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:v1497_CodvrNoCodvin', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(v1497_CodvrNoCodvin); v1497_CodvrNoCodvin.setVisibility(false); $('#v1497_CodvrNoCodvin').click(function() { v1497_CodvrNoCodvin.setVisibility(this.checked); }); var v1497_noCodvr = new OpenLayers.Layer.WMS( "v1497_noCodvr", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:v1497_noCodvr', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(v1497_noCodvr); v1497_noCodvr.setVisibility(false); $('#v1497_noCodvr').click(function() { v1497_noCodvr.setVisibility(this.checked); }); /***** fine anomalie ****/ /**** vincoli regionali ****/ var wms_sitap_v1497_pol_lettera_m = new OpenLayers.Layer.WMS( "wms_sitap_v1497_pol_lettera_m", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:wms_sitap_v1497_pol_lettera_m', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(wms_sitap_v1497_pol_lettera_m); wms_sitap_v1497_pol_lettera_m.setVisibility(false); $('#wms_sitap_v1497_pol_lettera_m').click(function() { wms_sitap_v1497_pol_lettera_m.setVisibility(this.checked); }); var wms_sitap_v1497_reg = new OpenLayers.Layer.WMS( "wms_sitap_v1497_reg", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:wms_sitap_v1497_reg', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(wms_sitap_v1497_reg); wms_sitap_v1497_reg.setVisibility(false); $('#wms_sitap_v1497_reg').click(function() { wms_sitap_v1497_reg.setVisibility(this.checked); }); var wms_sitap_v1497_pol_136 = new OpenLayers.Layer.WMS( "wms_sitap_v1497_pol_136", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:wms_sitap_v1497_136', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(wms_sitap_v1497_pol_136); wms_sitap_v1497_pol_136.setVisibility(false); $('#wms_sitap_v1497_pol_136').click(function() { wms_sitap_v1497_pol_136.setVisibility(this.checked); }); /**** fine vincoli regionali ****/ var unesco_buffer = new OpenLayers.Layer.WMS( "vw_unesco_buffer", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:vw_unesco_buffer2', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(unesco_buffer); unesco_buffer.setVisibility(false); var unesco_sito = new OpenLayers.Layer.WMS( "vw_unesco_sito", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:vw_unesco_sito', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(unesco_sito); unesco_sito.setVisibility(false); $('#unesco').click(function() { unesco_sito.setVisibility(this.checked); unesco_buffer.setVisibility(this.checked); }); var benitutelati = new OpenLayers.Layer.WMS( "benitutelati", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_benitutelati2', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(benitutelati); benitutelati.setVisibility(false); $('#benitutelati').click(function() { benitutelati.setVisibility(this.checked); }); var tab_usi_civici = new OpenLayers.Layer.WMS( "tab_usi_civici", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_usi_civici', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(tab_usi_civici); tab_usi_civici.setVisibility(false); $('#tab_usi_civici').click(function() { tab_usi_civici.setVisibility(this.checked); }); var tab_giardini = new OpenLayers.Layer.WMS( "tab_giardini", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_giardini_2', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(tab_giardini); tab_giardini.setVisibility(false); $('#tab_giardini').click(function() { tab_giardini.setVisibility(this.checked); }); var pcn_sic = new OpenLayers.Layer.WMS( "pcn_sic", "http://2.42.228.242:8080/geoserver/wms", { LAYERS: 'apar:SP.SITIPROTETTI_SIC', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(pcn_sic); pcn_sic.setVisibility(false); $('#pcn_sic').click(function() { pcn_sic.setVisibility(this.checked); }); var pcn_zps = new OpenLayers.Layer.WMS( "pcn_zps", "http://2.42.228.242:8080/geoserver/wms", { LAYERS: 'apar:SP.SITIPROTETTI.ZPS', STYLES: '', format: 'image/png', transparent: 'true' }, { ratio: 1, displayOutsideMaxExtent: true, isBaseLayer: false, 'visibility': true, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(pcn_zps); pcn_zps.setVisibility(false); $('#pcn_zps').click(function() { pcn_zps.setVisibility(this.checked); }); /******************************************* VIR *****************************************/ var tab_vir_geo_aree_archeol_vincolate = new OpenLayers.Layer.WMS( "tab_vir_geo_aree_archeol_vincolate -", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_vir_geo_aree_archeol_vincolate', STYLES: '', format: 'image/png', transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, isBaseLayer: false, opacity: 0.5, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(tab_vir_geo_aree_archeol_vincolate); tab_vir_geo_aree_archeol_vincolate.setVisibility(false); $('#tab_vir_geo_aree_archeol_vincolate').click(function() { tab_vir_geo_aree_archeol_vincolate.setVisibility(this.checked); }); var tab_vir_v_geo_anagrafica_beni = new OpenLayers.Layer.WMS( "tab_vir_v_geo_anagrafica_beni -", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_vir_v_geo_anagrafica_beni', STYLES: '', format: 'image/png', transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, isBaseLayer: false, projection: new OpenLayers.Projection("EPSG:900913") } ); map.addLayer(tab_vir_v_geo_anagrafica_beni); tab_vir_v_geo_anagrafica_beni.setVisibility(false); $('#tab_vir_v_geo_anagrafica_beni').click(function() { tab_vir_v_geo_anagrafica_beni.setVisibility(this.checked); }); /******************************************* fine VIR *****************************************/ /**** limiti amministrativi *****/ var tab_regioniistat_2011 = new OpenLayers.Layer.WMS( "tab_regioniistat_2011", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_regioniistat_2011', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(tab_regioniistat_2011); tab_regioniistat_2011.setVisibility(false); $('#tab_regioniistat_2011').click(function() { tab_regioniistat_2011.setVisibility(this.checked); }); $('#tab_regioniistat_2011').attr('checked', false); var tab_provinceistat_2011 = new OpenLayers.Layer.WMS( "tab_provinceistat_2011", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_provinceistat_2011', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(tab_provinceistat_2011); tab_provinceistat_2011.setVisibility(false); $('#tab_provinceistat_2011').click(function() { tab_provinceistat_2011.setVisibility(this.checked); }); $('#tab_provinceistat_2011').attr('checked', false); var tab_comuniistat_2011 = new OpenLayers.Layer.WMS( "tab_comuniistat_2011", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_comuniistat_2011', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(tab_comuniistat_2011); tab_comuniistat_2011.setVisibility(false); $('#tab_comuniistat_2011').click(function() { tab_comuniistat_2011.setVisibility(this.checked); }); $('#tab_comuniistat_2011').attr('checked', false); /**** fine limiti amministrativi *****/ /*boschi*/ var tab_vasvia_boschi = new OpenLayers.Layer.WMS( "tab_vasvia_boschi", "http://sitap.beniculturali.it:8080/geoserver/wms", { LAYERS: 'apar:tab_vasvia_boschi', STYLES: '', format: 'image/png', tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom, transparent: 'true' }, { buffer: 0, displayOutsideMaxExtent: true, opacity: 0.5 } ); map.addLayer(tab_vasvia_boschi); tab_vasvia_boschi.setVisibility(false); $('#tab_vasvia_boschi').click(function() { tab_vasvia_boschi.setVisibility(this.checked); }); $('#tab_vasvia_boschi').attr('checked', false); var style = { 'default': { fillColor: "#44bb44", strokeColor: "#33aa33"}, 'temporary': { fillColor: "#33ff33", strokeColor: "#33aa33"}, 'select': { fillColor: "#33ff33", strokeColor: "#33aa33"} }; addLayer('parchi', 'Parchi', 'geometry/parchi/', mergeStyle(style, base_style)); var rispetto = new OpenLayers.Layer.TileCache("Aree di rispetto", "cache", 'rispetto', {format: 'image/png', transparent: 'false'}); rispetto.isBaseLayer = false; rispetto.setVisibility(false); map.addLayer(rispetto); $('#rispetto').click(function() { rispetto.setVisibility(this.checked); }); $('#rispetto').attr('checked', false); var style = { 'default': { fillColor: "#00cccc", strokeColor: "#00aaaa"}, 'temporary': { fillColor: "#33ffff", strokeColor: "#00aaaa"}, 'select': { fillColor: "#33ffff", strokeColor: "#00aaaa"}}; addLayer('umide', 'Zone umide', 'geometry/umide/', mergeStyle(style, base_style)); var style = { 'default': { fillColor: "#cc0000", strokeColor: "#aa0000"}, 'temporary': { fillColor: "#ff3333", strokeColor: "#aa0000"}, 'select': { fillColor: "#ff3333", strokeColor: "#aa0000"} }; addLayer('vulcani', 'Vulcani', 'geometry/vulcani/', mergeStyle(style, base_style)); var style = { 'default': { fillColor: "#cccccc", strokeColor: "#777777"}, 'temporary': { fillColor: "#ffffff", strokeColor: "#777777"}, 'select': { fillColor: "#ffffff", strokeColor: "#777777"} }; var stylemap = mergeStyle(style, base_style); addLayer('curve', 'Curve di livello', 'geometry/curve/', stylemap); var style = { 'default': { strokeColor: "#777", fillColor: "#cccccc" } }; current_rischio = 'r_tot'; var context = { getRischio: function(f) { var val = f.attributes[current_rischio]; var intervals = rischi.intervals[current_rischio]; var colors = rischi.colors; if (val < intervals[0]) return colors[0]; if (val < intervals[1]) return colors[1]; if (val < intervals[2]) return colors[2]; return colors[3]; return '#ff0000'; } }; var stylemap = new OpenLayers.StyleMap({ 'default': new OpenLayers.Style({ strokeColor: "#777", fillColor: "${getRischio}", fillOpacity: 0.5, strokeWidth:"1" } , {context:context}), 'temporary': { strokeColor: "#333", fillOpacity: 0.5 }, 'select': { strokeColor: "#777", fillOpacity: 0.5 } }); addLayer('rischi', 'Vincoli a rischio', 'geometry/rischi/', stylemap); layers['rischi'].layer.setVisibility(false); $('#select_rischio').change(function(t) { current_rischio = $('#select_rischio').val(); layers['rischi'].layer.redraw();}); var style = { 'default': { fillColor: "#aa8800", strokeColor: "#884400", strokeWidh: 2}, 'temporary': { fillColor: "#aaaa00", strokeColor: "#888800", strokeWidh: 2}, 'select': { fillColor: "#aaaa00", strokeColor: "#777", strokeWidh: 2} }; edit = new OpenLayers.Layer.Vector('edit', {styleMap: mergeStyle(style, base_style)}); edit.setVisibility(false); map.addLayer(edit); var style = { 'default': { fillColor: "#aa8800", strokeColor: "#884400", strokeWidh: 2}, 'temporary': { fillColor: "#aaaa00", strokeColor: "#888800", strokeWidh: 2}, 'select': { fillColor: "#aaaa00", strokeColor: "#777", strokeWidh: 2} }; edit_vincolo = new OpenLayers.Layer.Vector('Geometria Vincolo 2', {styleMap: mergeStyle(style, base_style)}); edit_vincolo.setVisibility(false); map.addLayer(edit_vincolo); edit_vincolo.events.on({ 'featureselected': function(feature) { edit_vincolo.removeAllFeatures(); clearInfo(); return false; //display your message here }, 'featureunselected': function(feature) { //hide message } }); edit_select = new OpenLayers.Layer.Vector('editable', {styleMap: mergeStyle(style, base_style)}); edit_select.setVisibility(false); map.addLayer(edit_select); edit_select.events.on({ 'featureselected': function(feature) { edit_select.removeAllFeatures(); clearInfo(); return false; //display your message here }, 'featureunselected': function(feature) { //hide message } }); var style = { 'default': { fillColor: "#d7bcf2", strokeColor: "#b291d4", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 }, 'temporary': { fillColor: "#e6d4f9", strokeColor: "#b291d4", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 }, 'select': { fillColor: "#e6d4f9", strokeColor: "#b291d4", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 } }; var proposte = new OpenLayers.Layer.Vector('Proposte di vincolo', {styleMap: mergeStyle(style, base_style), hack:'proposte'}); proposte.isBaseLayer = false; proposte.setVisibility(false); map.addLayer(proposte); $('#proposte').click( function() { if(!proposte_loaded) { $.ajax({ type: 'GET', url: "layer_proposte.php", processData: true, dataType: "json", success: function(json) { parseWKT(proposte, json); }, error: function(x,y,z) { alert(y + ':' + z); } }); proposte_loaded = true; } proposte.setVisibility(this.checked); }); $('#proposte').attr('checked', false); highlightCtrl = new OpenLayers.Control.SelectFeature(proposte, { hover: true, highlightOnly: true, renderIntent: "temporary" }); map.addControl(highlightCtrl); highlightCtrl.activate(); highlightCtrl.handlers.feature.clickTolerance = 2; highlightCtrl.handlers.feature.stopDown = false; highlightCtrl.handlers.feature.stopUp = false; highlightCtrl.handlers.feature.stopClick = false; function onSelect(f) { identifyObject(f); var fields = {'397_shp':'codvr', 'Vincoli 1497':'codvr', 'Vincoli NEW 1497':'codvr', 'Parchi':'denominazi', 'Zone umide':'codzu', 'Vulcani':'id', 'Curve di livello':'id', 'Vincoli a rischio':'codvr', 'Proposte di vincolo':'codvr'}; var field = fields[f.layer.name]; var value = f.attributes[field]; f.layer.selected = {field:field, value:value}; //debug: alert("(map.js) - selected:"+value); } function onUnselect(f) { clearInfo(); f.layer.selected = null; } selectControl = new OpenLayers.Control.SelectFeature( [v1497_shp, layers['vincoli'].layer, layers['parchi'].layer, layers['umide'].layer, layers['vulcani'].layer, layers['curve'].layer, proposte, layers['rischi'].layer], { clickout: true, toggle: false, multiple: false, hover: false, toggleKey: "ctrlKey", // ctrl key removes from selection multipleKey: "shiftKey", // shift key adds to selection onSelect: onSelect, onUnselect: onUnselect } ); selectControl.handlers.feature.stopDown = false; selectControl.handlers.feature.stopUp = false; selectControl.handlers.feature.stopClick = false; map.addControl(selectControl); selectControl.activate(); controls = { point: new OpenLayers.Control.DrawFeature(edit, OpenLayers.Handler.Point), line: new OpenLayers.Control.DrawFeature(edit, OpenLayers.Handler.Path), polygon: new OpenLayers.Control.DrawFeature(edit, OpenLayers.Handler.Polygon), modify: new OpenLayers.Control.ModifyFeature(edit), drag: new OpenLayers.Control.DragFeature(edit), remove: new OpenLayers.Control.SelectFeature(edit, { title: "Delete Feature", onSelect: removeFeature, displayClass: "olControlDeleteFeature"}) }; var tools = ['point','line', 'polygon', 'modify', 'drag', 'remove', 'save', 'cancel']; for(var i = 0; i < tools.length; i++ ) { var action = tools[i]; $('#'+action).click(function(a) { return function() { editAction(a); } }(action)); } for(var key in controls) map.addControl(controls[key]); $('#openstreetmap') .click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(openstreetmap); sitap.setVisibility(false); }); $('#street') .click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(gmap); sitap.setVisibility(false); }); //$('#physical') .click(function() { if(this.checked) setBaseLayer(gphy); }); $('#hybrid') .click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(ghyb); sitap.setVisibility(false); }); $('#satellite').click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(gsat); sitap.setVisibility(false); }); $('#sitap') .click(function() { if(this.checked) { sitap.setVisibility(this.checked); //alert("sposta sitap sulla base"); map.setLayerIndex(sitap, 0); //set the image overlay to the bottom //carico nessuna base come base map.removeLayer(gphy); setBaseLayer(gphy); } }); $('#igm') .click(function() { if(this.checked) setBaseLayer(igm); sitap.setVisibility(false); }); $('#igm_storici') .click(function() { if(this.checked) setBaseLayer(igm_storici); sitap.setVisibility(false); }); $('#igm_wms') .click(function() { //TRUCCO PER NON AVERE NESSUNA BASE: ELIMINO IL LAYER GPHY E LO RICHIAMO COME BASE map.removeLayer(gphy); setBaseLayer(gphy); }); $('#igm25000') .click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(igm25000); sitap.setVisibility(false); }); $('#igm100000') .click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(igm100000); sitap.setVisibility(false); }); $('#igm250000') .click(function() { map.addLayer(gphy); if(this.checked) setBaseLayer(igm250000); sitap.setVisibility(false); }); function getVincolo(e) { if ($('#v1497_shp').attr('checked')) { //alert("getvincolo"); //alert("$('#v1497_shp').attr('checked') = " + $('#v1497_shp').attr('checked')); //var geojson = new OpenLayers.Format.GeoJSON(); // Get the mercator coordinates from the viewport var xy = map.getLonLatFromViewPortPx(e.xy); //alert("xy.lon=" + xy.lon + " - xy.lat=" + xy.lat); var lonlat = xy.lon + "|" + xy.lat; var codvr = 0; var url = "vincolo_load.php"; $.ajax({ type: 'POST', url: url, data: {lonlat: lonlat}, success: function(data) { if(data == 0) { alert("Nessun vincolo presente"); //edit_select.editing = false; return; } codvr = data; alert("Identificato vincolo CODVR = " + codvr); editShapeByCodvr(codvr); $('#info').load('info.php', { layer: "v1497_shp", id:codvr }); }, error: function(x,y,z) { alert(y + ':' + z); edit_select.editing = false;} }); } } } //fine di init() function init2() { var options = { //projection: new OpenLayers.Projection("EPSG:900913"), //displayProjection: new OpenLayers.Projection("EPSG:32632"), units: "m", //maxResolution: 156543.0339, maxResolution: 99.22366015624993, maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34) }; /* MAP CREATION AND CONTROLS */ map = new OpenLayers.Map('map_dettaglio', options); var panzoom = new OpenLayers.Control.PanZoomBar({slideFactor: 200}); panzoom.zoomWorldIcon = true; map.addControl(panzoom); map.removeControl (map.controls [1]); //Pannello di zoom e pan con stile personalizzato (olControlNavToolbar_aumi) //in maniera da inserire le icone custom OpenLayers.Control.CustomNavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, { /** * Constructor: OpenLayers.Control.NavToolbar * Add our two mousedefaults controls. * * Parameters: * options - {Object} An optional object whose properties will be used to extend the control. */ initialize: function(options) { OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]); this.addControls([ new OpenLayers.Control.Navigation({dblclick:false}), //Here it come new OpenLayers.Control.ZoomBox({alwaysZoom:true}) ]); // To make the custom navtoolbar use the regular navtoolbar style this.displayClass = 'olControlNavToolbar_aumi' }, /** * Method: draw * calls the default draw, and then activates mouse defaults. */ draw: function() { var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments); this.activateControl(this.controls[0]); return div; } } ); var panel = new OpenLayers.Control.CustomNavToolbar({position: new OpenLayers.Pixel(15,50)}); map.addControl(panel); //scalebar scalebar = new OpenLayers.Control.ScaleBar({ div: document.getElementById("scalebar"), minWidth: 75, maxWidth: 175 }); map.addControl(scalebar); //alert("init2"); //REMOVE ME [debug to visualize resolution //map.events.register('zoomend', map, writeScale); map.addControl(new OpenLayers.Control.KeyboardDefaults()); //map.addControl(new OpenLayers.Control.LayerSwitcher()); var external_control = new OpenLayers.Control.MousePosition({ div: document.getElementById('location') }); map.addControl(external_control); //visualizza scala: var scaleControl = map.addControl(new OpenLayers.Control.Scale(null, { updateScale: function() { var scale = map.getScale(); //alert("scale=" + scale); if (scale) { document.getElementById('scale').innerHTML = "1 : " + OpenLayers.Number.format(Math.round(scale), 0, "."); } } })); // OpenStreetMap var openstreetmap = new OpenLayers.Layer.OSM.Mapnik("OSM", {isBaseLayer:true, displayInLayerSwitcher:true, numZoomLevels: 20}); map.addLayer(openstreetmap); baseLayers = [openstreetmap]; map.setCenter(new OpenLayers.LonLat(1200000, 5400000, 0), 5); format = new OpenLayers.Format.GeoJSON({ 'internalProjection': map.baseLayer.projection, 'externalProjection': map.baseLayer.projection }); wkt = new OpenLayers.Format.WKT({ 'internalProjection': map.baseLayer.projection, 'externalProjection': map.baseLayer.projection }); var base_style = { 'default': { fillColor: "#ddcc00", strokeColor: "#aaaa00", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 }, 'temporary': { fillColor: "#fff79d", strokeColor: "#aaaa00", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 }, 'select': { fillColor: "#fff79d", strokeColor: "#aaaa00", strokeWidth: 1, pointRadius: 4, fillOpacity: 0.5 } }; var style = { 'default': { fillColor: "#f60925", strokeColor: "#f60925", strokeWidh: 1, strokeOpacity: 1}, 'temporary': { fillColor: "#aaaa00", strokeColor: "#888800", strokeWidh: 2}, 'select': { fillColor: "#aaaa00", strokeColor: "#777", strokeWidh: 2} }; edit = new OpenLayers.Layer.Vector('Geometria Vincolo', {styleMap: mergeStyle(style, base_style)}); edit.setVisibility(false); map.addLayer(edit); var style = base_style; //set up a save strategy var WGS84_UTM32N = new OpenLayers.Projection("EPSG:32632"); // WGS84 Google Mercator projection var WGS84_google_mercator = new OpenLayers.Projection("EPSG:900913"); var mapextent = new OpenLayers.Bounds(445169, 4214431, 3037913, 6366898).transform(WGS84_UTM32N, WGS84_google_mercator); } //fine di init2() function mostraLayersByZoom() { //gestione dei layer vestiti a seconda della scala var scale = map.getScale(); //alert("scale=" + scale); if (scale < 200000) { document.getElementById("tab_vasvia_boschi").disabled = false; } else { document.getElementById("tab_vasvia_boschi").disabled = true; } } function enlarge() { $('#legend').css('display', 'none'); $('#info').css('display', 'none'); if($('#controls').css('display') == 'none') $('#map').css({'position': 'absolute', 'left':'0px', 'top':'-12px', 'width': '100%', 'height': '100%'}); else { $('#map').css({'position': 'absolute', 'left':'0px', 'top':'-12px', 'width': '100%', 'height':'auto', 'bottom': '80px'}); $('#controls').css({'position':'absolute', 'top':($('#map').height() + 20) +'px' }); } map.render(document.getElementById('map')); } function stampaMappaCorrente() { //alert("stampa mappa corrente"); //alert("getcenter=" + map.getCenter()); var zoom = map.getZoom(); //alert("zoom: "+ zoom); var layers = ""; for (var i = 0; i < map.layers.length; i++) { if(map.layers[i].visibility == true){ //get a string of visible layers layers = layers + map.layers[i].name + ',' } } //remove the trailing ',' layers = layers.slice(0, -1); //alert("layers = " + layers); var printurl = 'http://sitap.beniculturali.it/stampa_mappa_elaborastampa.php?l=' + layers + '&lon=' + map.getCenter().lon + '&lat=' + map.getCenter().lat + '&zoom=' + map.getZoom(); window.open(printurl, "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400"); } function restrict() { $('#legend').css('display', 'block'); $('#info').css('display', 'block'); $('#map').css('position', 'relative'); $('#map').css('left', '0px'); $('#map').css('width', '740px'); $('#map').css('height', '475px'); $('#controls').css('position','relative'); $('#controls').css('top', '0px'); map.render(document.getElementById('map')); } function setBaseLayer(layer) { for(var i = 0; i < baseLayers.length; i++) baseLayers[i].setVisibility(false); map.setBaseLayer(layer); layer.setVisibility(true); } function addLayer(name, label, path, styleMap) { var options = { styleMap: styleMap, path: path, hack: name }; var layer = new MRLayer(label, format, options); layers[name] = layer; map.addLayer(layer.layer); layer.layer.setVisibility(false); $('#'+name).click(function() { layer.layer.setVisibility(this.checked); }); $('#'+name).attr('checked', false); } /* INFO AND EDITING STUFF */ function identifyObject(feature) { var id = -1; var attr = feature.attributes; var html = ""; var detail = ""; var layer = feature.layer; //alert('identify:'+attr.codvr + ' ' + feature.layer.name); switch(feature.layer.name) { case "v1497_shp": $('#info').load('info.php', { layer:feature.layer.name, id:attr.codvr }); return; } switch(layer.hack) { case "vincoli": $('#info').load('info.php', { layer:layer.hack, id:attr.codvr }); return; case "v1497_shp": $('#info').load('info.php', { layer:layer.hack, id:attr.codvr }); return; case "proposte": $('#info').load('info.php', { layer:layer.hack, id:attr.id }); return; case "vulcani": detail = attr.nome; html = "

Zone vulcaniche

"+attr.nome+"

"; break; case "umide": html = "

Zone umide

Codice zona umida: " + attr.codzu + "

"; break; case "parchi": detail = attr.denominazi; if(attr.codice) html = "

Parchi Nazionali

" + attr.denominazi + "

"; else html = "

Parchi Regionali

" + attr.denominazi + "

"; break; case "curve": detail = "Quota: " + attr.quota + "m"; html = "

Curve di livello

Quota: " + attr.quota + "m

"; break; case "rischi": detail = "Rischio " + rischi.names[current_rischio] + ": " + attr[current_rischio]; html = "

Rischi

" + ""; for(var i in rischi.names) { html += ""; } html += "
Rischio " + rischi.names[i] + "" + attr[i] + "
"; break; } if(detail != "") { if(popup) { map.removePopup(popup); popup.destroy(); } popup = new OpenLayers.Popup.FramedCloud("popup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(200,200), detail, null, false); map.addPopup(popup); } if(html != "") $('#info').html(html); } function clearInfo(e) { $('#info').html(""); if (popup) { map.removePopup(popup); popup.destroy(); popup = null; } } function setButton(button, on) { if(on) $('#'+button+' img').attr('src', 'img/'+button+'_on.jpg'); else $('#'+button+' img').attr('src', 'img/'+button+'_off.jpg'); } function editAction(action) { if(controls[action] && controls[action].active) { controls[action].deactivate(); setButton(action, false); return; } for(var i in controls) { if(i != "undo") { controls[i].deactivate(); setButton(i, i == action); } } switch(action) { case 'modify': controls.modify.mode = OpenLayers.Control.ModifyFeature.RESHAPE; controls.modify.activate(); break; case 'drag': controls.drag.activate(); break; case 'save': saveShape(); //edit.editing = false; //$('#controls').hide(); //edit.setVisibility(false); break; case 'cancel': var features = Array(); for(var i = 0; i < edit.features.length; i++) features.push(edit.features[i]); for(var i = 0; i < features.length; i++) edit.removeFeatures(features[i]); edit.editing = false; selectControl.activate(); $('#controls').hide(); $('#menu').show(); $('#submenu').show(); $('#map').removeClass('border'); $('#modificaGeometria').html(""); break; case 'remove': controls.remove.activate(); break; case 'point': controls.point.activate(); break; case 'line': controls.line.activate(); break; case 'polygon': controls.polygon.activate(); break; } } function getFeatureByValue(layer, value, field) { if(field == null) field = 'id'; var features = layer.layer.features; var ret = []; for(var i = 0; i < features.length; i++) { if(features[i].attributes[field] == value) { ret.push(features[i]); } } return ret; } function zoomToVisibleShape(layer, value, field) { var layer = layers[layer]; var features = getFeatureByValue(layer, value, field); if(features.length == 0) return // for(i in features) // selectControl.select(features[i]); var bounds = features[0].geometry.bounds; for(i in features) bounds.extend(features[i].geometry.bounds); // map.panTo(bounds.top, bounds.left); map.zoomToExtent(bounds); selectVisibleShape(layer, value, field); } function highlightVisibleShape(layer, value, field) { var layer = layers[layer]; var features = getFeatureByValue(layer, value, field); for(i in features) { highlightCtrl.highlight(features[i]); } } function selectVisibleShape(layer, value, field) { var layer = layers[layer]; layer.selected = { field:field, value:value }; layer.select(layer.layer.features); } var edit_id = null; //variables una mappa javascript qualsiasi... { layer: vincoli, id: 10 } function editShape(id) { //if(edit_vincolo.editing) return; //or should is ask to save and exit? edit_vincolo.editing = true; edit_id = id; clearAllLayers(); var url = "geom_load.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { //alert(data); edit_vincolo.editing = false; return; } var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit_vincolo.addFeatures(shape); //compute bounding box var bounds = new OpenLayers.Bounds(); for(var i = 0; i < shape.length; i++) bounds.extend(shape[i].geometry.getBounds()); expand(bounds, 4000); map.zoomToExtent(bounds); var selectFeature = new OpenLayers.Control.SelectFeature(edit_vincolo); map.addControl(selectFeature); selectFeature.activate(); } edit_vincolo.setVisibility(true); selectControl.deactivate(); //$('#controls').show(); }, error: function(x,y,z) { alert(y + ':' + z); edit_vincolo.editing = false;} }); //estrai le linee var url = "geom_load_lin.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { //alert(data); edit_vincolo.editing = false; return; } if (data) { var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit_vincolo.addFeatures(shape); } edit_vincolo.setVisibility(true); } }, error: function(x,y,z) { alert(y + ':' + z); edit_vincolo.editing = false;} }); //estrai i punti var url = "geom_load_poi.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { //alert(data); edit_vincolo.editing = false; return; } if (data) { var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit_vincolo.addFeatures(shape); } edit_vincolo.setVisibility(true); } }, error: function(x,y,z) { alert(y + ':' + z); edit_vincolo.editing = false;} }); } //variables una mappa javascript qualsiasi... { layer: vincoli, id: 10 } function editGeometria(id) { //if(edit_vincolo.editing) return; //or should is ask to save and exit? edit.editing = true; edit_id = id; clearAllLayers(); edit.removeAllFeatures(); var url = "geom_load.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { //alert(data); edit.editing = false; return; } var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit.addFeatures(shape); //compute bounding box var bounds = new OpenLayers.Bounds(); for(var i = 0; i < shape.length; i++) bounds.extend(shape[i].geometry.getBounds()); expand(bounds, 4000); map.zoomToExtent(bounds); var selectFeature = new OpenLayers.Control.SelectFeature(edit); map.addControl(selectFeature); selectFeature.activate(); } edit.setVisibility(true); selectControl.deactivate(); //$('#controls').show(); }, error: function(x,y,z) { alert(y + ':' + z); edit.editing = false;} }); //estrai le linee var url = "geom_load_lin.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { //alert(data); edit.editing = false; return; } if (data) { var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit.addFeatures(shape); } edit.setVisibility(true); } }, error: function(x,y,z) { alert(y + ':' + z); edit.editing = false;} }); //estrai i punti var url = "geom_load_poi.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { //alert(data); edit.editing = false; return; } if (data) { var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit.addFeatures(shape); } edit.setVisibility(true); } }, error: function(x,y,z) { alert(y + ':' + z); edit.editing = false;} }); } /**************** gestione storico ******************/ function viewStoricoVincoliColore(id, nome, geom, colore) { // allow testing of specific renderers via "?renderer=Canvas", etc var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; var scale = map.getScale(); var textsize = "6px"; if (scale <= 150000) { textsize = "12px"; } if (scale > 150000 && scale <=250000) { textsize = "10px"; } if (scale > 250000 && scale <=450000) { textsize = "8px"; } var vectorLayerColore = new OpenLayers.Layer.Vector("Storico", { styleMap: new OpenLayers.StyleMap({'default':{ strokeColor: colore, strokeOpacity: 1, strokeWidth: 3, fillColor: colore, fillOpacity: 0.5, pointRadius: 4, pointerEvents: "visiblePainted", label : nome, fontColor: colore, fontSize: textsize, fontFamily: "Verdana", fontWeight: "bold", labelAlign: "${align}", labelXOffset: "${xOffset}", labelYOffset: "${yOffset}", labelOutlineColor: "white", labelOutlineWidth: 3 }}), renderers: renderer }); var shape = wkt.read(geom); var polygonFeature = new OpenLayers.Format.WKT().read(geom); //var polygonFeature = new OpenLayers.Feature.Vector( // new OpenLayers.Geometry.Polygon(shape)); var polygonFeature = wkt.read(geom); vectorLayerColore.addFeatures(polygonFeature); vectorLayerColore.setVisibility(true); map.addLayer(vectorLayerColore); var zindex = id; map.setLayerIndex(vectorLayerColore, zindex); } function RemoveStorico() { //alert("rimuovi storico"); var lyr_list = map.getLayersByName("Storico"); for (var i in lyr_list) { lyr_list[i].removeAllFeatures(); map.removeLayer(lyr_list[i]); } } function PulisciLayer(nome_layer) { //alert("pulisci layer: " + nome_layer); var lyr_list = map.getLayersByName(nome_layer); for (var i in lyr_list) { lyr_list[i].removeAllFeatures(); //map.removeLayer(lyr_list[i]); } } /****** fine gestione storico ********/ //variables una mappa javascript qualsiasi... { layer: vincoli, id: 10 } function editShapeByCodvr(codvr) { edit_select.removeAllFeatures(); // if(edit_select.editing) return; //or should is ask to save and exit? // edit_select.editing = true; //alert("(editShapeByCodvr) codvr = " + codvr); edit_id = codvr; clearAllLayers(); var url = "geom_load_codvr.php"; $.ajax({ type: 'POST', url: url, data: {codvr: codvr}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { alert(data); //edit_select.editing = false; return; } var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit_select.addFeatures(shape); //compute bounding box /* ELIMINARE L'EFFETTO PAN+ZOOM (richiesta di Laria) var bounds = new OpenLayers.Bounds(); for(var i = 0; i < shape.length; i++) bounds.extend(shape[i].geometry.getBounds()); expand(bounds, 4000); map.zoomToExtent(bounds); */ var selectFeature = new OpenLayers.Control.SelectFeature(edit_select); map.addControl(selectFeature); selectFeature.activate(); } edit_select.setVisibility(true); selectControl.deactivate(); //$('#controls').show(); }, error: function(x,y,z) { alert(y + ':' + z); edit_select.editing = false;} }); //estrai le linee var url = "geom_load_lin_codvr.php"; $.ajax({ type: 'POST', url: url, data: {codvr: codvr}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { alert(data); //edit.editing = false; return; } if (data) { var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit_select.addFeatures(shape); } edit_select.setVisibility(true); } }, error: function(x,y,z) { alert(y + ':' + z); edit_select.editing = false;} }); //estrai i punti var url = "geom_load_poi_codvr.php"; $.ajax({ type: 'POST', url: url, data: {codvr: codvr}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { alert("problema: " + data); //edit.editing = false; return; } if (data) { //alert("trovato punto"); var shape = wkt.read(data); if(data != "GEOMETRYCOLLECTION()") { edit_select.addFeatures(shape); } edit_select.setVisibility(true); } }, error: function(x,y,z) { alert(y + ':' + z); edit_select.editing = false;} }); } /*visualizza dettagli*/ function editShapeDettaglio(id) { alert('edita shape'); if(edit.editing) return; //or should is ask to save and exit? edit.editing = true; edit_id = id; clearAllLayers(); var url = "geom_load.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 18) != "GEOMETRYCOLLECTION") { alert(data); edit.editing = false; return; } var shape = wkt.read(data); //var shape = wkt.read('GEOMETRYCOLLECTION(POLYGON((1502904.59779119 5407230.9678054,1496789.63552892 5404173.48669674,1495413.76902071 5396682.6579248,1513758.65580851 5388427.45881088,1517274.75910832 5395001.04322687,1502904.59779119 5407230.9678054)),POINT(1493885.02845438 5408645.05284286),LINESTRING(1510471.86359069 5411263.0210256,1512153.47821299 5400867.58517889,1522472.47702949 5404230.8144081,1525606.39518901 5392383.07502188))'); //alert("shape=" + shape); if(data != "GEOMETRYCOLLECTION()") { edit.addFeatures(shape); //compute bounding box var bounds = new OpenLayers.Bounds(); for(var i = 0; i < shape.length; i++) bounds.extend(shape[i].geometry.getBounds()); expand(bounds, 2000); map.zoomToExtent(bounds); } edit.setVisibility(true); selectControl.deactivate(); //$('#controls').show(); }, error: function(x,y,z) { alert(y + ':' + z); edit.editing = false;} }); } function editShapeDettaglio3(id, geom) { //visualizza la geometria senza passare per ajax if(edit.editing) return; //or should is ask to save and exit? edit.editing = true; edit_id = id; clearAllLayers(); var shape = wkt.read(geom); edit.addFeatures(shape); //compute bounding box var bounds = new OpenLayers.Bounds(); for(var i = 0; i < shape.length; i++) bounds.extend(shape[i].geometry.getBounds()); expand(bounds, 2000); map.zoomToExtent(bounds); edit.setVisibility(true); selectControl.deactivate(); } /* fine dettagli*/ function editShapeDettaglio4(id, geom, geomlin, geompoi) { //visualizza la geometria senza passare per ajax if(edit.editing) return; //or should is ask to save and exit? edit.editing = true; edit_id = id; clearAllLayers(); if (geomlin != "GEOMETRYCOLLECTION()") { //alert(geomlin); var shapelin = wkt.read(geomlin); edit.addFeatures(shapelin); } if (geompoi != "GEOMETRYCOLLECTION()") { var shapepoi = wkt.read(geompoi); edit.addFeatures(shapepoi); } if (geom != "GEOMETRYCOLLECTION()") { var shape = wkt.read(geom); edit.addFeatures(shape); } //compute bounding box var bounds = new OpenLayers.Bounds(); for(var i = 0; i < shape.length; i++) bounds.extend(shape[i].geometry.getBounds()); expand(bounds, 2000); map.zoomToExtent(bounds); edit.setVisibility(true); } /* fine dettagli*/ function importShape(id, geom) { //alert("importShape"); edit.editing = true; edit_id = id; if (geom != "GEOMETRYCOLLECTION()") { var shape = wkt.read(geom); edit.addFeatures(shape); } map.zoomToExtent(edit.getDataExtent()); return false; } function zoomToShape(id, layer, field, value) { var url = "bbox.php"; $.ajax({ type: 'POST', url: url, data: {id: id}, success: function(data) { if(data.substr(0, 1) != "{") { alert(data); return; } var bounds = jQuery.parseJSON(data); bounds = new OpenLayers.Bounds(bounds.w, bounds.s, bounds.e, bounds.n); expand(bounds, 2000); layers[layer].layer.selected = { field:field, value:value } map.zoomToExtent(bounds); }, error: function(x,y,z) { alert(y + ':' + z); } }); } function saveShape() { var features = edit.features; var data = "GEOMETRYCOLLECTION("; var count = 0; for(var i = 0; i < features.length; i++) { if(count != 0) data += ","; data += wkt.write(features[i]); count++; } data += ")"; $.post('geom_save.php', {id: edit_id, geom: data} , function(data){ if(data.length>0) alert(data); }); } function removeFeature(e) { edit.removeFeatures(e); } function parseWKT(layer, json) { var bounds; for(var i in json) { var features = wkt.read(json[i]); for(var k = 0; k < features.length; k++) features[k].attributes['id'] = i; if(features) { if(features.constructor != Array) { features = [features]; } for(var i=0; i