From e1232b4e5b149bdac2cad2bd39c9e83206713d00 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Fri, 19 Mar 2010 21:46:33 +0000 Subject: [PATCH] Inclusão da função "salvar" que permite listar as geometrias selecionadas e chamar uma função para salvar os dados. --- mashups/openlayers.css | 6 ++++++ mashups/openlayers.js.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ mashups/openlayers.php | 51 +++++++++++++++++++++++++++++---------------------- mashups/openlayers.png | Bin 16632 -> 0 bytes 4 files changed, 97 insertions(+), 28 deletions(-) diff --git a/mashups/openlayers.css b/mashups/openlayers.css index bad79c8..7ea0402 100644 --- a/mashups/openlayers.css +++ b/mashups/openlayers.css @@ -89,6 +89,12 @@ background-position:-406px 0; background-position:-406px -28px; } +.olControlEditingToolbar .salvaItemInactive { +background-position:-435px 0; +} +.olControlEditingToolbar .salvaItemActive { +background-position:-435px -28px; +} .olControlEditingToolbar { diff --git a/mashups/openlayers.js.php b/mashups/openlayers.js.php index 71c64f4..1f47de2 100644 --- a/mashups/openlayers.js.php +++ b/mashups/openlayers.js.php @@ -9,6 +9,7 @@ if (app==='N'){navn=true;}else{navm=true;} OpenLayers.ImgPath = "../pacotes/openlayers/img/" OpenLayers.Lang.setCode("pt-BR"); i3GEOOL = { + nomeFuncaoSalvar: "i3GEOOL.testeSalvar()", ol_mma: new OpenLayers.Layer.WMS( "Base cartográfica", "http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/baseraster.map&", @@ -24,7 +25,7 @@ i3GEOOL = { "http://t1.hypercube.telascience.org/cgi-bin/landsat7", {layers: "landsat7"} ), - layergrafico: new OpenLayers.Layer.Vector("Edição"), + layergrafico: new OpenLayers.Layer.Vector("Edição",{displayInLayerSwitcher:true,visibility:true}), layersIniciais: [ 0){ + ins += "

Foram encontrada(s) "+n+" geometria(s) selecionada(s)

"; + ins += "

Listar geometrias "; + ins += "Salvar geometria(s)

"; + YAHOO.salvaGeometrias.container.panel.setBody(ins); + } + else + {alert("Selecione pelo menos um elemento");} + }, + listaGeometriasSel: function(){ + var geos = i3GEOOL.layergrafico.selectedFeatures; + var n = geos.length; + var ins = ""; + for(i=0;i
"+geos[i].geometry+"

"; + ins += "Atributos: "+i+"
"; + var a = geos[i].attributes; + var keys = []; + for(key in a){ + if(a[key]){ + ins += key+" = "+a[key]+"
"; + } + } + } + var w = window.open(); + w.document.write(ins); + w.document.close(); + }, + testeSalvar: function(){ + alert("Funcao nao disponivel. Defina o nome da funcao em i3GEOOL.nomeFuncaoSalvar "); + }, criaBotoes: function(botoes){ var sketchSymbolizers = { "Point": { @@ -317,7 +365,6 @@ i3GEOOL = { new OpenLayers.Rule({symbolizer: sketchSymbolizers}) ]); var styleMap = new OpenLayers.StyleMap({"default": style}); - var adiciona = false; var controles = new Array(); var panel = new OpenLayers.Control.Panel({ @@ -510,7 +557,16 @@ i3GEOOL = { }); controles.push(button); var adiciona = true; - } + } + if(botoes.salva==true){ + var button = new OpenLayers.Control.Button({ + displayClass: "salva", + trigger: function(){i3GEOOL.salvaGeometrias();}, + title: "Salvar" + }); + controles.push(button); + var adiciona = true; + } // //adiciona o painel ao mapa se alguma op��o foi inserida // diff --git a/mashups/openlayers.php b/mashups/openlayers.php index 1c1baca..7995723 100644 --- a/mashups/openlayers.php +++ b/mashups/openlayers.php @@ -91,6 +91,7 @@ if(!isset($botoes)){ $objBotoes[] = "'edita':true"; $objBotoes[] = "'apaga':true"; $objBotoes[] = "'procura':true"; + $objBotoes[] = "'salva':true"; } else{ $botoes = str_replace(" ",",",$botoes); @@ -122,36 +123,41 @@ else{ {$objBotoes[] = "'apaga':true";} if(in_array("procura",$botoes)) {$objBotoes[] = "'procura':false";} + if(in_array("salva",$botoes)) + {$objBotoes[] = "'salva':false";} } $botoes = "{".implode(",",$objBotoes)."}"; // //define quais os layers que comporão o mapa // -$temas = str_replace(" ",",",$temas); -$temas = strtolower($temas); -$temas = explode(",",$temas); -$layers = array(); -$objOpenLayers = array(); -if(isset($servidor) && $servidor != "../ogc.php"){ - $layers = $temas; - foreach($temas as $tema){ - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?tema='.$tema.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{isBaseLayer:false})'; +if($temas != "") +{ + $temas = str_replace(" ",",",$temas); + $temas = strtolower($temas); + $temas = explode(",",$temas); + $layers = array(); + $objOpenLayers = array(); + if(isset($servidor) && $servidor != "../ogc.php"){ + $layers = $temas; + foreach($temas as $tema){ + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?tema='.$tema.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{isBaseLayer:false})'; + } } -} -else{ - foreach($temas as $tema){ - if(file_exists("../temas/".$tema.".map")){ - $maptemp = @ms_newMapObj("../temas/".$tema.".map"); - for($i=0;$i<($maptemp->numlayers);++$i) - { - $layern = $maptemp->getLayer($i); - $layers[] = $layern->name; + else{ + foreach($temas as $tema){ + if(file_exists("../temas/".$tema.".map")){ + $maptemp = @ms_newMapObj("../temas/".$tema.".map"); + for($i=0;$i<($maptemp->numlayers);++$i) + { + $layern = $maptemp->getLayer($i); + $layers[] = $layern->name; + } + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.($layern->getmetadata("tema")).'", "../ogc.php?tema='.$tema.'&",{layers:"'.implode(",",$layers).'",transparent: "true", format: "image/png"},{isBaseLayer:false})'; } - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.($layern->getmetadata("tema")).'", "../ogc.php?tema='.$tema.'&",{layers:"'.implode(",",$layers).'",transparent: "true", format: "image/png"},{isBaseLayer:false})'; + else + {echo $tema." não foi encontrado.
";} + $layers = array(); } - else - {echo $tema." não foi encontrado.
";} - $layers = array(); } } function ajuda(){ @@ -188,6 +194,7 @@ Parâmetros: apaga captura procura + salva Para ver a lista de códigos de temas, que podem ser utilizados no parâmetro 'temas', acesse: lista de temas. Os códigos são mostrados em vermelho. diff --git a/mashups/openlayers.png b/mashups/openlayers.png index 3d88830..91a2690 100644 Binary files a/mashups/openlayers.png and b/mashups/openlayers.png differ -- libgit2 0.21.2