Commit e1232b4e5b149bdac2cad2bd39c9e83206713d00

Authored by Edmar Moretti
1 parent 457febad

Inclusão da função "salvar" que permite listar as geometrias selecionadas e cham…

…ar uma função para salvar os dados.
mashups/openlayers.css
... ... @@ -89,6 +89,12 @@ background-position:-406px 0;
89 89 background-position:-406px -28px;
90 90 }
91 91  
  92 +.olControlEditingToolbar .salvaItemInactive {
  93 +background-position:-435px 0;
  94 +}
  95 +.olControlEditingToolbar .salvaItemActive {
  96 +background-position:-435px -28px;
  97 +}
92 98  
93 99  
94 100 .olControlEditingToolbar {
... ...
mashups/openlayers.js.php
... ... @@ -9,6 +9,7 @@ if (app==='N'){navn=true;}else{navm=true;}
9 9 OpenLayers.ImgPath = "../pacotes/openlayers/img/"
10 10 OpenLayers.Lang.setCode("pt-BR");
11 11 i3GEOOL = {
  12 + nomeFuncaoSalvar: "i3GEOOL.testeSalvar()",
12 13 ol_mma: new OpenLayers.Layer.WMS(
13 14 "Base cartográfica",
14 15 "http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/baseraster.map&",
... ... @@ -24,7 +25,7 @@ i3GEOOL = {
24 25 "http://t1.hypercube.telascience.org/cgi-bin/landsat7",
25 26 {layers: "landsat7"}
26 27 ),
27   - layergrafico: new OpenLayers.Layer.Vector("Edição"),
  28 + layergrafico: new OpenLayers.Layer.Vector("Edição",{displayInLayerSwitcher:true,visibility:true}),
28 29 layersIniciais: [<?php
29 30 if(isset($objOpenLayers) && $objOpenLayers != "")
30 31 {echo implode(",",$objOpenLayers);}
... ... @@ -54,9 +55,10 @@ i3GEOOL = {
54 55 i3GEOOL.mapa.addLayers(alayers);
55 56 if(i3GEOOL.layersIniciais != "")
56 57 {i3GEOOL.mapa.addLayers(i3GEOOL.layersIniciais);}
57   - if(i3GEOOL.layergrafico != "")
58   - {i3GEOOL.mapa.addLayers(i3GEOOL.layergrafico);}
59   -
  58 +
  59 + if(i3GEOOL.layergrafico != ""){
  60 + i3GEOOL.mapa.addLayers([i3GEOOL.layergrafico]);
  61 + }
60 62  
61 63 i3GEOOL.mapa.zoomToMaxExtent();
62 64 i3GEOOL.coordenadas();
... ... @@ -287,6 +289,52 @@ i3GEOOL = {
287 289 }
288 290 })
289 291 },
  292 + salvaGeometrias: function(){
  293 + try{
  294 + YAHOO.namespace("salvaGeometrias.container");
  295 + YAHOO.salvaGeometrias.container.panel = new YAHOO.widget.Panel("panelsalvageometrias", {zIndex:2000, iframe:false, width:"250px", visible:false, draggable:true, close:true } );
  296 + YAHOO.salvaGeometrias.container.panel.setHeader("Geometrias");
  297 + YAHOO.salvaGeometrias.container.panel.setBody("");
  298 + YAHOO.salvaGeometrias.container.panel.setFooter("");
  299 + YAHOO.salvaGeometrias.container.panel.render(document.body);
  300 + YAHOO.salvaGeometrias.container.panel.center();
  301 + }
  302 + catch(e){}
  303 + YAHOO.salvaGeometrias.container.panel.show();
  304 + var geos = i3GEOOL.layergrafico.selectedFeatures;
  305 + var n = geos.length;
  306 + var ins = "";
  307 + if(n > 0){
  308 + ins += "<p class=paragrafo >Foram encontrada(s) "+n+" geometria(s) selecionada(s) </p>";
  309 + ins += "<p class=paragrafo ><a href='#' onclick='i3GEOOL.listaGeometriasSel()' > Listar geometrias</a> ";
  310 + ins += "<a href='#' onclick='"+i3GEOOL.nomeFuncaoSalvar+"' >Salvar geometria(s)</a></p>";
  311 + YAHOO.salvaGeometrias.container.panel.setBody(ins);
  312 + }
  313 + else
  314 + {alert("Selecione pelo menos um elemento");}
  315 + },
  316 + listaGeometriasSel: function(){
  317 + var geos = i3GEOOL.layergrafico.selectedFeatures;
  318 + var n = geos.length;
  319 + var ins = "";
  320 + for(i=0;i<n;i++){
  321 + ins += "<b>Geometria: "+i+"</b><br>"+geos[i].geometry+"<br><br>";
  322 + ins += "<b>Atributos: "+i+"</b><br>";
  323 + var a = geos[i].attributes;
  324 + var keys = [];
  325 + for(key in a){
  326 + if(a[key]){
  327 + ins += key+" = "+a[key]+"<br>";
  328 + }
  329 + }
  330 + }
  331 + var w = window.open();
  332 + w.document.write(ins);
  333 + w.document.close();
  334 + },
  335 + testeSalvar: function(){
  336 + alert("Funcao nao disponivel. Defina o nome da funcao em i3GEOOL.nomeFuncaoSalvar ");
  337 + },
290 338 criaBotoes: function(botoes){
291 339 var sketchSymbolizers = {
292 340 "Point": {
... ... @@ -317,7 +365,6 @@ i3GEOOL = {
317 365 new OpenLayers.Rule({symbolizer: sketchSymbolizers})
318 366 ]);
319 367 var styleMap = new OpenLayers.StyleMap({"default": style});
320   -
321 368 var adiciona = false;
322 369 var controles = new Array();
323 370 var panel = new OpenLayers.Control.Panel({
... ... @@ -510,7 +557,16 @@ i3GEOOL = {
510 557 });
511 558 controles.push(button);
512 559 var adiciona = true;
513   - }
  560 + }
  561 + if(botoes.salva==true){
  562 + var button = new OpenLayers.Control.Button({
  563 + displayClass: "salva",
  564 + trigger: function(){i3GEOOL.salvaGeometrias();},
  565 + title: "Salvar"
  566 + });
  567 + controles.push(button);
  568 + var adiciona = true;
  569 + }
514 570 //
515 571 //adiciona o painel ao mapa se alguma op��o foi inserida
516 572 //
... ...
mashups/openlayers.php
... ... @@ -91,6 +91,7 @@ if(!isset($botoes)){
91 91 $objBotoes[] = "'edita':true";
92 92 $objBotoes[] = "'apaga':true";
93 93 $objBotoes[] = "'procura':true";
  94 + $objBotoes[] = "'salva':true";
94 95 }
95 96 else{
96 97 $botoes = str_replace(" ",",",$botoes);
... ... @@ -122,36 +123,41 @@ else{
122 123 {$objBotoes[] = "'apaga':true";}
123 124 if(in_array("procura",$botoes))
124 125 {$objBotoes[] = "'procura':false";}
  126 + if(in_array("salva",$botoes))
  127 + {$objBotoes[] = "'salva':false";}
125 128 }
126 129 $botoes = "{".implode(",",$objBotoes)."}";
127 130 //
128 131 //define quais os layers que comporão o mapa
129 132 //
130   -$temas = str_replace(" ",",",$temas);
131   -$temas = strtolower($temas);
132   -$temas = explode(",",$temas);
133   -$layers = array();
134   -$objOpenLayers = array();
135   -if(isset($servidor) && $servidor != "../ogc.php"){
136   - $layers = $temas;
137   - foreach($temas as $tema){
138   - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?tema='.$tema.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{isBaseLayer:false})';
  133 +if($temas != "")
  134 +{
  135 + $temas = str_replace(" ",",",$temas);
  136 + $temas = strtolower($temas);
  137 + $temas = explode(",",$temas);
  138 + $layers = array();
  139 + $objOpenLayers = array();
  140 + if(isset($servidor) && $servidor != "../ogc.php"){
  141 + $layers = $temas;
  142 + foreach($temas as $tema){
  143 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?tema='.$tema.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{isBaseLayer:false})';
  144 + }
139 145 }
140   -}
141   -else{
142   - foreach($temas as $tema){
143   - if(file_exists("../temas/".$tema.".map")){
144   - $maptemp = @ms_newMapObj("../temas/".$tema.".map");
145   - for($i=0;$i<($maptemp->numlayers);++$i)
146   - {
147   - $layern = $maptemp->getLayer($i);
148   - $layers[] = $layern->name;
  146 + else{
  147 + foreach($temas as $tema){
  148 + if(file_exists("../temas/".$tema.".map")){
  149 + $maptemp = @ms_newMapObj("../temas/".$tema.".map");
  150 + for($i=0;$i<($maptemp->numlayers);++$i)
  151 + {
  152 + $layern = $maptemp->getLayer($i);
  153 + $layers[] = $layern->name;
  154 + }
  155 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.($layern->getmetadata("tema")).'", "../ogc.php?tema='.$tema.'&",{layers:"'.implode(",",$layers).'",transparent: "true", format: "image/png"},{isBaseLayer:false})';
149 156 }
150   - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.($layern->getmetadata("tema")).'", "../ogc.php?tema='.$tema.'&",{layers:"'.implode(",",$layers).'",transparent: "true", format: "image/png"},{isBaseLayer:false})';
  157 + else
  158 + {echo $tema." não foi encontrado.<br>";}
  159 + $layers = array();
151 160 }
152   - else
153   - {echo $tema." não foi encontrado.<br>";}
154   - $layers = array();
155 161 }
156 162 }
157 163 function ajuda(){
... ... @@ -188,6 +194,7 @@ Parâmetros:
188 194 apaga
189 195 captura
190 196 procura
  197 + salva
191 198  
192 199 Para ver a lista de códigos de temas, que podem ser utilizados no parâmetro 'temas', acesse:
193 200 <a href='../ogc.php?lista=temas' >lista de temas</a>. Os códigos são mostrados em vermelho.
... ...
mashups/openlayers.png

16.2 KB | W: | H:

16.7 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin