From 8b17f02908fc2d44c44c0f515015e729ab301473 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Wed, 18 May 2011 22:22:29 +0000 Subject: [PATCH] Reengenharia do mashup OpenLayers para permitir o uso do javascript dentro do i3geo --- mashups/openlayers.js.php | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------- mashups/openlayers.php | 92 +++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- 2 files changed, 99 insertions(+), 84 deletions(-) diff --git a/mashups/openlayers.js.php b/mashups/openlayers.js.php index 342f447..46014fd 100644 --- a/mashups/openlayers.js.php +++ b/mashups/openlayers.js.php @@ -21,7 +21,6 @@ i3GEOOL = { {layers: 'basic'} ), jpl_wms: new OpenLayers.Layer.WMS( "NASA Global Mosaic", "http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"},{singleTile:true}), - osm_wms: new OpenLayers.Layer.WMS( "Open Street Map", "http://full.wms.geofabrik.de/std/demo_key?", @@ -36,45 +35,63 @@ i3GEOOL = { "Estados do Brasil", "http://mapas.mma.gov.br/i3geo/ogc.php?tema=estadosl&", {layers: "estadosl",FORMAT:'image/png'} - ), + ), + fundo: "ol_mma,ol_wms,jpl_wms,osm_wms,top_wms,est_wms", layergrafico: new OpenLayers.Layer.Vector("Edição",{displayInLayerSwitcher:true,visibility:true}), - layersIniciais: [], - botoes: , - pontos: [], - marca: "", - mapa: new OpenLayers.Map('i3geoMapa', { - controls: [ - - ], - numZoomLevels: , - maxExtent: new OpenLayers.Bounds() - }), + layersIniciais: [], + botoes: { + 'pan':true, + 'zoombox':true, + 'zoomtot':true, + 'legenda':true, + 'distancia':true, + 'area':true, + 'identifica':true, + 'linha':true, + 'ponto':true, + 'poligono':true, + 'edita':true, + 'apaga':true, + 'procura':true, + 'salva':true + }, + pontos: [], + marca: "../pacotes/openlayers/img/marker-gold.png", + controles: [ + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PanZoomBar(), + new OpenLayers.Control.LayerSwitcher({'ascending':false}), + new OpenLayers.Control.ScaleLine(), + new OpenLayers.Control.MousePosition({'separator':' '}), + new OpenLayers.Control.OverviewMap(), + new OpenLayers.Control.KeyboardDefaults() + ], + numzoom: 12, + maxext: new OpenLayers.Bounds(-76.5125927,-39.3925675209,-29.5851853,9.49014852081), + mapa: "", inicia: function(){ - var alayers = []; - =0;i--){ + try{ + eval("i3GEOOL."+fundo[i]+".transitionEffect = 'resize';"); + eval("i3GEOOL."+fundo[i]+".setVisibility(false);"); + eval("alayers.push(i3GEOOL."+fundo[i]+");"); + } + catch(e){alayers[0].setVisibility(true);} } - echo "try{alayers[0].setVisibility(true);}catch(e){}"; - ?> i3GEOOL.mapa.addLayers(alayers); if(i3GEOOL.layersIniciais != ""){ diff --git a/mashups/openlayers.php b/mashups/openlayers.php index c63ef0a..8e331fc 100644 --- a/mashups/openlayers.php +++ b/mashups/openlayers.php @@ -13,30 +13,10 @@ if(!isset($largura)) if(!isset($altura)) {$altura = 400;} // -//define o nível de zoom -// -if(!isset ($numzoomlevels)) -{$numzoomlevels = "6";} -// -//define a extensão geográfica que será aplicada -// -if(!isset($maxextent)) -{$maxextent = "-76.5125927 -39.3925675209 -29.5851853 9.49014852081";} -$maxextent = str_replace(" ",",",$maxextent); -// //define quais controles serão mostrados no mapa // $objControles = array(); -if(!isset($controles)){ - $objControles[] = "new OpenLayers.Control.Navigation()"; - $objControles[] = "new OpenLayers.Control.PanZoomBar()"; - $objControles[] = "new OpenLayers.Control.LayerSwitcher({'ascending':false})"; - $objControles[] = "new OpenLayers.Control.ScaleLine()"; - $objControles[] = "new OpenLayers.Control.MousePosition({'separator':' '})"; - $objControles[] = "new OpenLayers.Control.OverviewMap()"; - $objControles[] = "new OpenLayers.Control.KeyboardDefaults()"; -} -else{ +if(isset($controles)){ $controles = str_replace(" ",",",$controles); $controles = strtolower($controles); $controles = explode(",",$controles); @@ -59,23 +39,7 @@ else{ //define quais botoes serão mostrados no mapa // $objBotoes = array(); -if(!isset($botoes)){ - $objBotoes[] = "'pan':true"; - $objBotoes[] = "'zoombox':true"; - $objBotoes[] = "'zoomtot':true"; - $objBotoes[] = "'legenda':true"; - $objBotoes[] = "'distancia':true"; - $objBotoes[] = "'area':true"; - $objBotoes[] = "'identifica':true"; - $objBotoes[] = "'linha':true"; - $objBotoes[] = "'ponto':true"; - $objBotoes[] = "'poligono':true"; - $objBotoes[] = "'edita':true"; - $objBotoes[] = "'apaga':true"; - $objBotoes[] = "'procura':true"; - $objBotoes[] = "'salva':true"; -} -else{ +if(isset($botoes)){ $botoes = str_replace(" ",",",$botoes); $botoes = strtolower($botoes); $botoes = explode(",",$botoes); @@ -107,8 +71,9 @@ else{ {$objBotoes[] = "'procura':false";} if(in_array("salva",$botoes)) {$objBotoes[] = "'salva':false";} + $botoes = "{".implode(",",$objBotoes)."}"; } -$botoes = "{".implode(",",$objBotoes)."}"; + // //define a lista de layers do tipo baselayers //$fundo é um array com a lista dos nomes possíveis ou passados pela url @@ -118,9 +83,6 @@ if(isset($fundo) && $fundo != ""){ $fundo = str_replace(","," ",$fundo); $fundo = explode(" ",$fundo); } -else{ - $fundo = array("est_wms","ol_mma","ol_wms","jpl_wms","osm_wms","top_wms"); -} // //define quais os layers que comporão o mapa // @@ -147,10 +109,8 @@ if($temas != "") $layers[] = $layern->name; } $ebase = "false"; - if(in_array($tema,$fundo)) - { - $ebase = "true"; - } + if(isset($fundo) && in_array($tema,$fundo)) + {$ebase = "true";} $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.($layern->getmetadata("tema")).'", "../ogc.php?tema='.$tema.'&",{layers:"'.implode(",",$layers).'",transparent: "true", format: "image/png"},{isBaseLayer:'.$ebase.'})'; } else @@ -231,6 +191,7 @@ Parâmetros: + @@ -238,7 +199,44 @@ Parâmetros:
-- libgit2 0.21.2