Commit ec6ddfc09a5ea6ce2cd9322a941fe0c036d04fab

Authored by Edmar Moretti
1 parent 45e2567e

Correção no template da legenda utilizado no mashup, pois não estava montando co…

…rretamente a legenda de camadas WMS
aplicmap/legendaOgc.html
1 1 <!--
2 2 [leg_layer_html opt_flag=1]
3 3 <table style="border-spacing: 0; border-collapse: collapse; margin: 0px; padding: 2px;" class="tabelaItemLegenda">
4   - [/leg_layer_html] [leg_class_html] [if name=CLASSE oper=neq value=NAO]
  4 +[if name=legendawms oper=isset ]
  5 + <tr><td style=text-align:left ><img src='[metadata name=legendawms]' /></td></tr>
  6 +[/if]
  7 +[/leg_layer_html]
5 8  
  9 +[leg_class_html] [if name=CLASSE oper=neq value=NAO]
6 10 <tr>
7 11 <td class="tabelaItemLegendaIcone" width=16 style="border-spacing: 0; border-collapse: collapse; margin: 0px; padding: 2px;"><img src="[leg_icon width=16 height=16 ]" /></td>
8 12 <td style="border-spacing: 0; border-collapse: collapse; margin: 0px; padding: 0px; font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif;" class="tabelaItemLegendaNome"><span>[leg_class_name]</span></td>
9 13 </tr>
10   - [/if][/leg_class_html]
  14 +[/if][/leg_class_html]
11 15 </table>
12 16 -->
... ...
classesjs/classe_editorol.js
... ... @@ -623,6 +623,7 @@ i3GEO.editorOL = {
623 623 i3GEO.editorOL.mapa.zoomToExtent(b);
624 624 },
625 625 mostraLegenda: function(){
  626 + console.info(i3GEO.editorOL.layersLigados())
626 627 var layers = i3GEO.editorOL.layersLigados(),
627 628 nlayers = layers.length,
628 629 ins = "",i, icone = "",
... ...
mashups/openlayersdebug.php 0 → 100755
... ... @@ -0,0 +1,813 @@
  1 +<?php
  2 +/**
  3 + * DESLIGACACHE (opcional) {sim|nao} - forca a nao usar o cache de imagens qd
  4 + * definido como "sim", do contr&aacute;rio, o uso ou n&atilde;o do cache
  5 + * ser&aacute; definido automaticamente
  6 + */
  7 +include_once(dirname(__FILE__)."/../ms_configura.php");
  8 +include_once(dirname(__FILE__)."/../classesphp/sani_request.php");
  9 +include_once(dirname(__FILE__)."/../classesphp/carrega_ext.php");
  10 +include_once(dirname(__FILE__)."/../classesphp/funcoes_gerais.php");
  11 +error_reporting(0);
  12 +//variaveis utilizadas
  13 +$parurl = array_merge($_GET,$_POST);
  14 +$desligacache = $parurl["desligacache"];
  15 +$opacidade = $parurl["opacidade"];
  16 +$nocache = $parurl["nocache"];
  17 +$restauramapa = $parurl["restauramapa"];
  18 +$mapext = $parurl["mapext"];
  19 +$temas = $parurl["temas"];
  20 +$layers = $parurl["layers"];
  21 +
  22 +$altura = $parurl["altura"];
  23 +$largura = $parurl["largura"];
  24 +$controles = $parurl["controles"];
  25 +$botoes = $parurl["botoes"];
  26 +$fundo = $parurl["fundo"];
  27 +$visiveis = $parurl["visiveis"];
  28 +$servidor = $parurl["servidor"];
  29 +$kml = $parurl["kml"];
  30 +$numzoomlevels = $parurl["numzoomlevels"];
  31 +$minresolution = $parurl["minresolution"];
  32 +$maxextent = $parurl["maxextent"];
  33 +
  34 +$pontos = $parurl["pontos"];
  35 +$marca = $parurl["marca"];
  36 +$tiles = $parurl["tiles"];
  37 +$incluilayergrafico = $parurl["incluilayergrafico"];
  38 +$ativalayerswicther = $parurl["ativalayerswicther"];
  39 +$ativarodadomouse = $parurl["ativarodadomouse"];
  40 +$legendahtml = $parurl["legendahtml"];
  41 +$nocache = $parurl["nocache"];
  42 +
  43 +//cria as pastas temporarias caso nao existam
  44 +if (! file_exists ( $dir_tmp )) {
  45 + @mkdir ( $dir_tmp, 0744 );
  46 +}
  47 +if (file_exists ( $dir_tmp )) {
  48 + @mkdir ( $dir_tmp . "/comum", 0744 );
  49 + @mkdir ( $dir_tmp . "/saiku-datasources", 0744 );
  50 + chmod ( $dir_tmp . "/saiku-datasources", 0744 );
  51 + @mkdir ( $dir_tmp . "/cache", 0744 );
  52 + chmod ( $dir_tmp . "/cache", 0744 );
  53 + @mkdir ( $dir_tmp . "/cache/googlemaps", 0744 );
  54 + chmod ( $dir_tmp . "/cache/googlemaps", 0744 );
  55 +}
  56 +if(!empty($desligacache)){
  57 + $DESLIGACACHE = $desligacache;
  58 +}
  59 +if(empty($opacidade)){
  60 + $opacidade = 1;
  61 +}
  62 +//
  63 +//verifica se em cada camada deve ser inserido um parametro aleatorio para evitar cache de imagem do lado do cliente
  64 +//
  65 +if($nocache == "sim"){
  66 + $nocache = "a".mt_rand(0, 1000)."&";
  67 +}
  68 +else{
  69 + $nocache = "";
  70 +}
  71 +//guarda os parametros das camadas que possuem plugins configurados
  72 +$temasPluginI3Geo = array();
  73 +//
  74 +// recupera um mapa salvo no banco de administracao
  75 +//
  76 +if(!empty($restauramapa)){
  77 + $xbase = restauraMapaAdmin($restauramapa,$dir_tmp);
  78 + validaAcessoTemas($xbase,true);
  79 + $m = ms_newMapObj($xbase);
  80 + $w = $m->web;
  81 + $w->set("imagepath",dirname($w->imagepath)."/");
  82 + $w->set("imageurl",dirname($w->imageurl)."/");
  83 + // apaga algumas camadas
  84 + $l = $m->getlayerbyname("rosadosventos");
  85 + if($l != ""){
  86 + $l->set("status",MS_DELETE);
  87 + }
  88 + $l = $m->getlayerbyname("copyright");
  89 + if($l != ""){
  90 + $l->set("status",MS_DELETE);
  91 + }
  92 + $m->save($xbase);
  93 + $temas = $xbase;
  94 + if (!isset($mapext)){
  95 + $mapext = $m->extent->minx." ".$m->extent->miny." ".$m->extent->maxx." ".$m->extent->maxy;
  96 + }
  97 +}
  98 +if(!isset($mapext)){
  99 + $versao = versao();
  100 + $versao = $versao["principal"];
  101 + if(isset($base) && $base != ""){
  102 + if(file_exists($base)){
  103 + $f = $base;
  104 + }
  105 + else{
  106 + $f = $locaplic."/aplicmap/".$base.".map";
  107 + }
  108 + }
  109 + else
  110 + {
  111 + $f = "";
  112 + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){
  113 + $f = $locaplic."/aplicmap/geral1windowsv".$versao.".map";
  114 + }
  115 + else{
  116 + if($f == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){
  117 + $f = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map";
  118 + }
  119 + if($f == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
  120 + $f = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map";
  121 + }
  122 + if($f == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){
  123 + $f = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map";
  124 + }
  125 + if($f == "")
  126 + {
  127 + $f = $locaplic."/aplicmap/geral1v".$versao.".map";
  128 + }
  129 + }
  130 + }
  131 + if(@ms_newMapObj($f)){
  132 + $mapae = ms_newMapObj($f);
  133 + $c = $mapae->extent;
  134 + $mapext = $c->minx.",".$c->miny.",".$c->maxx.",".$c->maxy;
  135 + }
  136 +}
  137 +//
  138 +// imprime na tela a ajuda ao usu&aacute;rio
  139 +//
  140 +if(!isset($temas) && isset($layers)){
  141 + $temas = $layers;
  142 +}
  143 +if(!isset($temas)){
  144 + ajuda();
  145 +}
  146 +// problema na vers&atilde;o 211 do OpenLayers. Tamanho em % n&atilde;o &eacute;
  147 +// aceito
  148 +// if(!isset($largura))
  149 + // {$largura = 500;}
  150 +if(isset($largura) && !isset($altura)){
  151 + $altura = $largura;
  152 +}
  153 +if(isset($altura) && !isset($largura)){
  154 + $largura = $altura;
  155 +}
  156 +//
  157 +// define quais controles ser&atilde;o mostrados no mapa
  158 +//
  159 +$objControles = array();
  160 +if(isset($controles)){
  161 + $controles = str_replace(" ",",",$controles);
  162 + $controles = strtolower($controles);
  163 + $controles = explode(",",$controles);
  164 + if(in_array("navigation",$controles)){
  165 + $objControles[] = "new OpenLayers.Control.Navigation()";
  166 + }
  167 + if(in_array("panzoombar",$controles)){
  168 + $objControles[] = "new OpenLayers.Control.PanZoomBar()";
  169 + }
  170 + if(in_array("layerswitcher",$controles)){
  171 + $objControles[] = "new OpenLayers.Control.LayerSwitcher({'ascending':false})";
  172 + }
  173 + if(in_array("scaleline",$controles)){
  174 + $objControles[] = "new OpenLayers.Control.ScaleLine()";
  175 + }
  176 + if(in_array("mouseposition",$controles))
  177 + {
  178 + $objControles[] = "new OpenLayers.Control.MousePosition({'separator':' '})";
  179 + }
  180 + if(in_array("overviewmap",$controles)){
  181 + $objControles[] = "new OpenLayers.Control.OverviewMap()";
  182 + }
  183 + if(in_array("keyboarddefaults",$controles)){
  184 + $objControles[] = "new OpenLayers.Control.KeyboardDefaults()";
  185 + }
  186 +}
  187 +//
  188 +// define quais botoes ser&atilde;o mostrados no mapa
  189 +//
  190 +$objBotoes = array();
  191 +if(isset($botoes)){
  192 + $botoes = str_replace(" ",",",$botoes);
  193 + $botoes = strtolower($botoes);
  194 + $botoes = explode(",",$botoes);
  195 + if(in_array("pan",$botoes)){
  196 + $objBotoes[] = "'pan':true";
  197 + }
  198 + if(in_array("zoombox",$botoes)){
  199 + $objBotoes[] = "'zoombox':true";
  200 + }
  201 + if(in_array("zoomtot",$botoes)){
  202 + $objBotoes[] = "'zoomtot':true";
  203 + }
  204 + if(in_array("zoomout",$botoes)){
  205 + $objBotoes[] = "'zoomout':true";
  206 + }
  207 + if(in_array("zoomin",$botoes))
  208 + {
  209 + $objBotoes[] = "'zoomin':true";
  210 + }
  211 + if(in_array("legenda",$botoes)){
  212 + $objBotoes[] = "'legenda':true";
  213 + }
  214 + if(in_array("distancia",$botoes)){
  215 + $objBotoes[] = "'distancia':true";
  216 + }
  217 + if(in_array("area",$botoes)){
  218 + $objBotoes[] = "'area':true";
  219 + }
  220 + if(in_array("identifica",$botoes)){
  221 + $objBotoes[] = "'identifica':true";
  222 + }
  223 + if(in_array("linha",$botoes)){
  224 + $objBotoes[] = "'linha':true";
  225 + }
  226 + if(in_array("ponto",$botoes)){
  227 + $objBotoes[] = "'ponto':true";
  228 + }
  229 + if(in_array("poligono",$botoes)){
  230 + $objBotoes[] = "'poligono':true";
  231 + }
  232 + if(in_array("edita",$botoes)){
  233 + $objBotoes[] = "'edita':true";
  234 + }
  235 + if(in_array("listag",$botoes)){
  236 + $objBotoes[] = "'listag':true";
  237 + }
  238 + if(in_array("corta",$botoes)){
  239 + $objBotoes[] = "'corta':true";
  240 + }
  241 + if(in_array("apaga",$botoes)){
  242 + $objBotoes[] = "'apaga':true";
  243 + }
  244 + if(in_array("procura",$botoes)){
  245 + $objBotoes[] = "'procura':true";
  246 + }
  247 + if(in_array("salva",$botoes)){
  248 + $objBotoes[] = "'salva':true";
  249 + }
  250 + if(in_array("ajuda",$botoes)){
  251 + $objBotoes[] = "'ajuda':true";
  252 + }
  253 + if(in_array("fecha",$botoes)){
  254 + $objBotoes[] = "'fecha':true";
  255 + }
  256 + if(in_array("tools",$botoes)){
  257 + $objBotoes[] = "'tools':true";
  258 + }
  259 + if(in_array("undo",$botoes)){
  260 + $objBotoes[] = "'undo':true";
  261 + }
  262 + if(in_array("propriedades",$botoes)){
  263 + $objBotoes[] = "'propriedades':true";
  264 + }
  265 + if(in_array("frente",$botoes)){
  266 + $objBotoes[] = "'frente':true";
  267 + }
  268 + if(in_array("texto",$botoes)){
  269 + $objBotoes[] = "'texto':true";
  270 + }
  271 + if(in_array("novaaba",$botoes)){
  272 + $objBotoes[] = "'novaaba':true";
  273 + }
  274 + $botoes = "{".implode(",",$objBotoes)."}";
  275 +}
  276 +
  277 +//
  278 +// define a lista de layers do tipo baselayers
  279 +// $fundo &eacute; um array com a lista dos nomes poss&iacute;veis ou passados
  280 +// pela url
  281 +// cada um deve ser definido em openlayers.js.php
  282 +//
  283 +if(isset($fundo) && $fundo != ""){
  284 + $fundo = str_replace(","," ",$fundo);
  285 + $fundo = explode(" ",$fundo);
  286 +}
  287 +//
  288 +// define quais os layers que compor&atilde;o o mapa
  289 +//
  290 +//$objOpenLayers guarda a string javascript que sera usada para criar os objetos
  291 +//layer do OpenLayers
  292 +if(isset($temas)){
  293 + $objOpenLayers = array();
  294 +}
  295 +if($temas != ""){
  296 + $temas = str_replace(" ",",",$temas);
  297 + // $temas = strtolower($temas);
  298 + $temas = explode(",",$temas);
  299 + if(!isset($visiveis)){
  300 + $visiveis = $temas;
  301 + }
  302 + else{
  303 + $visiveis = str_replace(" ",",",$visiveis);
  304 + $visiveis = explode(",",$visiveis);
  305 + }
  306 + $objOpenLayers = array();
  307 + if(!isset($servidor)){
  308 + $servidor = "../ogc.php";
  309 + }
  310 + //
  311 + //lista de ferramentas
  312 + //lista os nomes de metadados que contem os parametros das
  313 + //ferramentas customizaveis e que seraco incluidas na propriedade do layer
  314 + //
  315 + $listaFerramentas = array("tme","storymap","animagif");
  316 + $dadosTemas = pegaDadosAdminKey("SELECT codigo_tema,link_tema FROM __esq__i3geoadmin_temas WHERE codigo_tema IN('".implode($temas,',')."')","__esq__");
  317 + foreach($temas as $tema){
  318 + //
  319 + //utilzado para obter os parametros de ferramentas especificas indicadas nos metadados do LAYER
  320 + //
  321 + $ferramentas = array();
  322 + if(file_exists($locaplic."/temas/".$tema.".gvp")){
  323 + include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php");
  324 + $gm = new gvsig2mapfile($locaplic."/temas/".$tema.".gvp");
  325 + $gvsigview = $gm->getViewsNames();
  326 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$gvsigview[0].'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{singleTile:false,visibility:true,isBaseLayer:false, ferramentas :'.$ferramentas.')';
  327 + }
  328 + else{
  329 + $nomeMap = "";
  330 + if(file_exists($locaplic."/temas/".$tema.".map")){
  331 + $nomeMap = $locaplic."/temas/".$tema.".map";
  332 + }
  333 + else{
  334 + if(file_exists($tema)){
  335 + $nomeMap = $tema;
  336 + }
  337 + else{
  338 + // acontece caso o mapfile tenha sido gerado na pasta
  339 + // temporaria por algum sistema
  340 + if(file_exists($dir_tmp."/".$tema.".map")){
  341 + $nomeMap = $dir_tmp."/".$tema.".map";
  342 + }
  343 + }
  344 + }
  345 + if($nomeMap != ""){
  346 + $layersNomes = array();
  347 + $layers = array();
  348 + $maptemp = @ms_newMapObj($nomeMap);
  349 + if($maptemp){
  350 + $nlayers = $maptemp->numlayers;
  351 + for($i=0;$i<($nlayers);++$i) {
  352 + $layern = $maptemp->getLayer($i);
  353 + //
  354 + //verifica se o layer contem ferramentas parametrizadas
  355 + //
  356 + foreach($listaFerramentas as $lf){
  357 + $meta = $layern->getmetadata($lf);
  358 + if($meta != ""){
  359 + $ferramentas[] = "'".$lf."':".$meta;
  360 + }
  361 + }
  362 + $ferramentas = '{'.implode(",",$ferramentas).'}';
  363 + if($layern->getmetadata("PLUGINI3GEO") != ""){
  364 + //obtem os dados necessarios para iniciar o plugin
  365 + //os objetos layer (openLayers) sao criados apenas no final
  366 + //do processo, pois necessitam usar javascript e nao apenas PHP
  367 + $temasPluginI3Geo[] = array(
  368 + "name"=>$layern->name,
  369 + "tema"=>$layern->getmetadata("tema"),
  370 + "plugin"=>$layern->getmetadata("PLUGINI3GEO"),
  371 + "cache"=>strtoupper($layern->getmetadata("cache")),
  372 + "transitioneffect"=>strtoupper($layern->getmetadata("transitioneffect")),
  373 + "tiles"=>strtoupper($layern->getmetadata("tiles")),
  374 + "posicaoLayer"=>count($objOpenLayers),
  375 + "ferramentas"=>$ferramentas
  376 + );
  377 + $objOpenLayers[] = "";
  378 + }
  379 + else{
  380 + $layersNomes[] = $layern->name;
  381 + $layers[] = $layern;
  382 + }
  383 + }
  384 + $nomeLayer = implode(",",$layersNomes);
  385 + $tituloLayer = $layern->getmetadata("tema");
  386 + $ebase = "false";
  387 + if(isset($fundo) && $fundo != ""){
  388 + if(in_array($tema,$fundo)){
  389 + $ebase = "true";
  390 + }
  391 + }
  392 + $visivel = "false";
  393 + if(in_array($tema,$visiveis)){
  394 + $visivel = "true";
  395 + }
  396 + if(strtolower($DESLIGACACHE) != "sim" && $nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM" && $layern->getmetadata("PLUGINI3GEO") == ""){
  397 + //
  398 + //obtem a fonte
  399 + //
  400 + $link_tema = $dadosTemas[$layern->name];
  401 + $link_tema = $link_tema["link_tema"];
  402 + if($layern->type != 2 && $layern->type != 3){
  403 + $opacidade = 1;
  404 + }
  405 + //
  406 + //verifica se deve aplicar filtro
  407 + //
  408 + $filtro = $_GET["map_layer_".$layern->name."_filter"];
  409 + if(!empty($filtro)){
  410 + $DESLIGACACHE = "sim";
  411 + $nocache = "map_layer_".$layern->name."_filter=".$filtro."&".$nocache;
  412 + }
  413 + $teffect = 'transitionEffect: "resize",';
  414 + if(strtoupper($layern->getmetadata("transitioneffect")) == "NAO"){
  415 + $teffect = 'transitionEffect: null,';
  416 + }
  417 + // nesse caso o layer e adicionado como TMS
  418 + // tms leva os parametros do TMS
  419 + if($layern->getmetadata("extensao") == ""){
  420 + $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{'.$teffect.' tileOrigin: new OpenLayers.LonLat(-180, -90),opacity:'.$opacidade.',serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png", ferramentas :'.$ferramentas.',link_tema:"'.$link_tema.'"})';
  421 + }
  422 + else{
  423 + $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{'.$teffect.' tileOrigin: new OpenLayers.LonLat(-180, -90),maxExtent:['.str_replace(" ",",",$layern->getmetadata("extensao")).'],opacity:'.$opacidade.',serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png", ferramentas :'.$ferramentas.',link_tema:"'.$link_tema.'"})';
  424 + }
  425 + // cria um clone WMS para efeitos de getfeatureinfo
  426 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,transitionEffect : null,singleTile:true,visibility:false,isBaseLayer:false, ferramentas :'.$ferramentas.',link_tema:"'.$link_tema.'"})';
  427 + }
  428 + else{
  429 + foreach($layers as $l){
  430 + $singleTile = "false";
  431 + if(strtoupper($l->getmetadata("TILES")) == "NAO"){
  432 + $singleTile = "true";
  433 + }
  434 + $tituloLayer = $l->getmetadata("tema");
  435 + $nomeLayer = $l->name;
  436 + $link_tema = $dadosTemas[$nomeLayer];
  437 + $link_tema = $link_tema["link_tema"];
  438 + $visivel = "false";
  439 + if($l->status == MS_DEFAULT || in_array($tema,$visiveis)){
  440 + $visivel = "true";
  441 + }
  442 + if($l->type != 2 && $l->type != 3){
  443 + $opacidade = 1;
  444 + }
  445 + //
  446 + //verifica se deve aplicar filtro
  447 + //
  448 + $filtro = $_GET["map_layer_".$l->name."_filter"];
  449 + if(!empty($filtro)){
  450 + $DESLIGACACHE = "sim";
  451 + $nocache = "map_layer_".$l->name."_filter=".$filtro."&".$nocache;
  452 + }
  453 + $teffect = 'transitionEffect: "resize",';
  454 + if(strtoupper($l->getmetadata("transitioneffect")) == "NAO"){
  455 + $teffect = 'transitionEffect: null,';
  456 + }
  457 + if($tituloLayer != ""){
  458 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{'.$teffect.' singleTile:'.$singleTile.',visibility:'.$visivel.',isBaseLayer:'.$ebase.', ferramentas :'.$ferramentas.',link_tema:"'.$link_tema.'"})';
  459 + }
  460 + else{
  461 + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{'.$teffect.' displayInLayerSwitcher:false,singleTile:'.$singleTile.',visibility:'.$visivel.',isBaseLayer:'.$ebase.', ferramentas :'.$ferramentas.',link_tema:"'.$link_tema.'"})';
  462 + }
  463 + }
  464 + }
  465 + }
  466 + }
  467 + else{
  468 + echo $tema." n&atilde;o foi encontrado.<br>";
  469 + }
  470 + }
  471 + }
  472 +}
  473 +function nomeRandomicoM($n=10){
  474 + $nomes = "";
  475 + $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ';
  476 + $max = 51;
  477 + for($i=0; $i < $n; ++$i)
  478 + {
  479 + $nomes .= $a{mt_rand(0, $max)};
  480 + }
  481 + return $nomes;
  482 +}
  483 +function ajuda(){
  484 + echo "
  485 + <pre><b>
  486 + Mashup OpenLayers
  487 + Par&acirc;metros:
  488 + restauramapa - id do mapa armazenado no sistema de administracao e que ser&aacute; restaurado para ser aberto novamente (veja em i3geo/admin/html/mapas.html)
  489 + opacidade - opacidade (de 0 a 1) aplicada aos temas do tipo poligonal ou raster (default 1)
  490 + kml - lista de endere&ccedil;os (url) de um arquivos kml que ser&atilde;o adicionados ao mapa. Separado por ','
  491 + servidor - por default &eacute; ../ogc.php o que for&ccedil;a o uso do i3geo local. Esse &eacute; o programa que ser&aacute; utilizado em conjunto com a lista definida no par&acirc;metro 'temas'
  492 + temas - lista com os temas (mapfiles) do i3Geo que ser&atilde;o inclu&iacute;dos no mapa. Pode ser inclu&iacute;do um arquivo mapfile que esteja fora da pasta i3geo/temas. Nesse caso, deve-se definir o caminho completo do arquivo e tamb&eacute;m o par&acirc;metro &layers
  493 + visiveis - lista de temas (mesmos nomes do par&acirc;metro temas) que iniciar&atilde;o como vis&iacute;veis no mapa. Se n&atilde;o for definido, todos os temas ser&atilde;o vis&iacute;veis.
  494 + numzoomlevels - n&uacute;mero de n&iacute;veis de zoom, default=12
  495 + minresolution - resolu&ccedil;&atilde;o m&iacute;nima. Utilizada para definir o primeiro n&iacute;vel de zoom. Default=0.703125
  496 + maxextent - extens&atilde;o geogr&aacute;fica m&aacute;xima do mapa (xmin,ymin,xmax,ymax)
  497 + mapext - extens&atilde;o geogr&aacute;fica inicial do mapa (xmin,ymin,xmax,ymax)
  498 + largura - lagura do mapa em pixels
  499 + altura - altura do mapa em pixels
  500 + pontos - lista de coordenadas x e y que ser&atilde;o inclu&iacute;das como marcas no mapa
  501 + marca - nome do arquivo que cont&eacute;m a imagem que ser&aacute; utilizada para mostrar as coordenadas
  502 + tiles (true|false) - indica se o modo tile ser&aacute; usado ou n&atilde;o (true por default). O modo tile pode tornar o mashup mais lento em algumas situa&ccedil;&otilde;es.
  503 + incluilayergrafico (true|false) - indica se o layer que recebe elementos gr&aacute;ficos ser&aacute; adicionado ou n&atilde;o ao mapa
  504 + ativalayerswicther (true|false) - inicia o mapa com a caixa de escolha das camadas (layerSwitcher) aberta ou n&atilde;o. Por default, inicia fechada
  505 + ativarodadomouse (true|false) - ativa ou n&atilde;o o zoom com base na roda do mouse (default &eacute; true)
  506 + legendahtml (true|false) - ativa ou n&atilde;o (default &eacute; false) a gera&ccedil;&atilde;o de legenda do tipo HTML no lugar de imagem png. Legendas HTML podem ser modificadas com base em CSS. A legenda &eacute; constru&iacute;da com o template i3geo/aplicmap/legendaOgc.html.
  507 + desligacache (sim|nao) - desativa o uso do cache de imagens em disco do lado do servidor, for&ccedil;ando a renderiza&ccedil;&atilde;o dos tiles de cada camada em cada requisi&ccedil;&atilde;o
  508 + nocache (sim) - evita o uso de imagens em cache existentes no navegador do usu&aacute;rio
  509 +
  510 + Filtros
  511 +
  512 + filtros podem ser adicionados incluindo o parametro da seguinte forma: &map_layer_<nomedotema>_filter=
  513 +
  514 + Exemplo de filtro
  515 +
  516 + ?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))
  517 +
  518 + no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA'
  519 +
  520 + fundo - lista com os nomes, separados por ',' dos layers que ser&atilde;o usados como fundo para o mapa. Se n&atilde;o for definido,
  521 + ser&aacute; usado o default. O primeiro da lista ser&aacute; o fundo ativo. Se na lista de temas de fundo estiver algum
  522 + tema incluido com o parametro 'temas', esses ser&atilde;o inclu&iacute;dos como temas de fundo.
  523 + Quando for vazio, o ultimo layer sera considerado como o layer de fundo
  524 + Os seguintes fundos podem usados nessa lista:
  525 +
  526 + e_oce - ESRI Ocean Basemap
  527 + e_ims - ESRI Imagery World 2D
  528 + e_wsm - ESRI World Street Map
  529 + ol_mma - base cartogr&aacute;fica do Brasil
  530 + ol_wms - base mundial da Meta Carta
  531 + top_wms - topon&iacute;mia do servidor do MMA usado no mapa de refer&ecirc;ncia
  532 + est_wms - estados do Brasil
  533 +
  534 + controles - lista com os nomes dos controles que ser&atilde;o adicionados ao mapa. Se n&atilde;o for definido, todos os controles ser&atilde;o adicionados
  535 + navigation
  536 + panzoombar
  537 + layerswitcher
  538 + scaleline
  539 + mouseposition
  540 + overviewmap
  541 + keyboarddefaults
  542 + botoes - lista com os nomes dos botoes que ser&atilde;o adicionados ao mapa. Se n&atilde;o for definido, todos os bot&otilde;es ser&atilde;o adicionados
  543 + pan
  544 + zoombox
  545 + zoomtot
  546 + zoomin
  547 + zoomout
  548 + distancia
  549 + area
  550 + identifica
  551 + ponto
  552 + linha
  553 + poligono
  554 + texto
  555 + edita
  556 + listag (lista geometrias)
  557 + apaga
  558 + captura
  559 + procura
  560 + frente
  561 + propriedades
  562 + tools
  563 + undo
  564 + salva
  565 + ajuda
  566 + fecha
  567 + corta
  568 + legenda
  569 + novaaba
  570 +
  571 + Para ver a lista de c&oacute;digos de temas, que podem ser utilizados no par&acirc;metro 'temas', acesse:
  572 + <a href='../ogc.php?lista=temas' >lista de temas</a>. Os c&oacute;digos s&atilde;o mostrados em vermelho.
  573 +
  574 + Exemplo:
  575 +
  576 + &lt;iframe height='400px' src='http://mapas.mma.gov.br/i3geo/mashups/openlayers.php?temas=bioma&amp;altura=350&amp;largura=350' style='border: 0px solid white;' width='400px'&gt;&lt;/iframe&gt;
  577 +
  578 + ";
  579 + exit;
  580 +}
  581 +?>
  582 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  583 +<html>
  584 +<head>
  585 +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
  586 +<meta name="viewport" content="width=device-width, initial-scale=1">
  587 +<script type="text/javascript" src="openlayers_compacto.js.php"></script>
  588 +<script type="text/javascript" src="../classesjs/classe_editorol.js"></script>
  589 +<?php
  590 +//carrega o script para layers do tipo plugin
  591 +if(count($temasPluginI3Geo) > 0){
  592 + echo '<script type="text/javascript" src="../classesjs/classe_plugini3geo.js"></script>'."\n";
  593 + //echo '<script type="text/javascript" src="../classesjs/compactados/classe_plugini3geo_compacto.js"></script>'."\n";
  594 + echo '<script type="text/javascript" src="../pacotes/cpaint/cpaint2_compacto.inc.js"></script>'."\n";
  595 +}
  596 +?>
  597 +<link rel="stylesheet" href="openlayers_compacto.css" type="text/css" />
  598 +
  599 +<style>
  600 +.yui-skin-sam .container-minimiza {
  601 + background: transparent
  602 + url(../pacotes/yui290/build/assets/skins/sam/sprite.png) no-repeat
  603 + scroll 0 -450px;
  604 + cursor: pointer;
  605 + height: 15px;
  606 + position: absolute;
  607 + right: 30px;
  608 + top: 1px;
  609 + width: 25px;
  610 + z-index: 2001;
  611 + opacity: .8;
  612 + filter: alpha(opacity = 80);
  613 +}
  614 +
  615 +.pluginParametrossql {
  616 + background-image: url("../imagens/gisicons/settings.png");
  617 + background-size: 14px auto;
  618 + cursor: pointer;
  619 + position: relative;
  620 + top: 3px;
  621 + width: 14px;
  622 +}
  623 +
  624 +.i3GEOiconeTme, .i3GEOiconeStorymap {
  625 + background-size: 14px auto;
  626 + cursor: pointer;
  627 + position: relative;
  628 + top: 2px;
  629 + width: 14px;
  630 + margin-right: 2px;
  631 +}
  632 +
  633 +.ajuda_usuario {
  634 + background-image: url(../imagens/external.png);
  635 + background-position: 0px 0px;
  636 + background-repeat: no-repeat;
  637 + margin-left: 0;
  638 + text-decoration: none;
  639 + cursor: help;
  640 + position: relative;
  641 + top: 2px;
  642 + font-size: 13px;
  643 +}
  644 +</style>
  645 +</head>
  646 +<body class=" yui-skin-sam">
  647 + <?php
  648 + if(isset($largura) && $largura != ""){
  649 + echo '<div id=i3geoMapa style="width:'.$largura.'px;height:'.$altura.'px;"></div>';
  650 + }
  651 + else{
  652 + echo '<div id=i3geoMapa style="width:0;height:0"></div>';
  653 + }
  654 +
  655 + ?>
  656 + <div id=i3geoSelTemaAtivo style="height: 15em; z-index: 3000; display: none" class=" yui-skin-sam"></div>
  657 + <script>
  658 +OpenLayers.ImgPath = "../pacotes/openlayers/img/";
  659 +OpenLayers.Lang.setCode("pt-BR");
  660 +var m = document.getElementById("i3geoMapa");
  661 +if(parseInt(m.style.width,10) === 0){
  662 + var t = i3GEO.util.tamanhoBrowser();
  663 + m.style.width = (t[0]-10)+"px";
  664 + m.style.height = (t[1]-20)+"px";
  665 +}
  666 +i3GEO.editorOL.layersIniciais = [<?php
  667 + if(isset($objOpenLayers) && $objOpenLayers != "")
  668 + {echo implode(",",$objOpenLayers);}
  669 + else
  670 + {echo "''";}
  671 +?>];
  672 +<?php if(isset($botoes)){
  673 + echo "i3GEO.editorOL.botoes = $botoes ;";
  674 +}
  675 +?>
  676 +i3GEO.editorOL.pontos = [<?php
  677 + if(isset($pontos)){
  678 + $pontos = str_replace(" ",",",$pontos);
  679 + echo $pontos;
  680 + }
  681 +?>];
  682 +i3GEO.editorOL.kml = [<?php
  683 + if(isset($kml)){
  684 + $kml = str_replace(" ",",",$kml);
  685 + $kml = explode(",",$kml);
  686 + echo "'".implode("','",$kml)."'";
  687 + }
  688 +?>];
  689 +i3GEO.editorOL.marca = "<?php
  690 + if(isset($marca)){echo $marca;}
  691 + else
  692 + {echo "../pacotes/openlayers/img/marker-gold.png";}
  693 +?>";
  694 +i3GEO.editorOL.tiles = "<?php
  695 + if(isset($tiles)){echo $tiles;}
  696 + else
  697 + {echo "true";}
  698 +?>";
  699 +i3GEO.editorOL.incluilayergrafico = "<?php
  700 + if(isset($incluilayergrafico)){echo $incluilayergrafico;}
  701 + else
  702 + {echo "true";}
  703 +?>";
  704 +i3GEO.editorOL.ativalayerswitcher = "<?php
  705 + if(isset($ativalayerswitcher)){echo $ativalayerswitcher;}
  706 + else
  707 + {echo "false";}
  708 +?>";
  709 +i3GEO.editorOL.ativarodadomouse = "<?php
  710 + if(isset($ativarodadomouse)){echo $ativarodadomouse;}
  711 + else
  712 + {echo "true";}
  713 +?>";
  714 +
  715 +i3GEO.editorOL.legendahtml = "<?php
  716 + if(isset($legendahtml)){echo $legendahtml;}
  717 + else
  718 + {echo "true";}
  719 +?>";
  720 +
  721 +<?php
  722 +if(isset($fundo) && $fundo != ""){
  723 + echo "i3GEO.editorOL.fundo = '".implode(",",$fundo)."';";
  724 +}
  725 +
  726 +if(isset($controles)){
  727 + echo "i3GEO.editorOL.controles = [".implode(",",$objControles)."];";
  728 +}
  729 +if(isset($numzoomlevels)){
  730 + echo "i3GEO.editorOL.numzoom = ".$numzoomlevels.";";
  731 +}
  732 +if(isset($minresolution)){
  733 + echo "i3GEO.editorOL.minresolution = ".$minresolution.";";
  734 +}
  735 +if(isset($maxextent)){
  736 + $maxextent = str_replace(" ",",",$maxextent);
  737 + echo "i3GEO.editorOL.maxext = new OpenLayers.Bounds(".$maxextent.");\n";
  738 +}
  739 +else{
  740 + echo "i3GEO.editorOL.maxext = new OpenLayers.Bounds(-76.5125927,-39.3925675209,-29.5851853,9.49014852081);\n";
  741 +}
  742 +if(isset($mapext)){
  743 + $mapext = str_replace(" ",",",$mapext);
  744 + echo "i3GEO.editorOL.mapext = new OpenLayers.Bounds(".$mapext.");\n";
  745 +}
  746 +if(empty($fundo)){
  747 + // echo "i3GEO.editorOL.mapa.allOverlays = true;";
  748 +}
  749 +?>
  750 +i3GEO.Interface = {openlayers:{googleLike:false}};
  751 +//evita que seja mostrada a opcao de salvar figura
  752 +i3GEO.editorOL.nomeFuncaoSalvar = "";
  753 +var temp = i3GEO.editorOL.minresolution,
  754 + r = [ i3GEO.editorOL.minresolution ];
  755 +for (var j = 0; j < (i3GEO.editorOL.numzoom - 1); j++) {
  756 + temp = temp / 2;
  757 + r.push(temp);
  758 +}
  759 +i3GEO.editorOL.incluilayergrafico = true;
  760 +i3GEO.editorOL.mapa = new OpenLayers.Map(
  761 + 'i3geoMapa',
  762 + {
  763 + autoUpdateSize: false,
  764 + controls:[],
  765 + resolutions: r,
  766 + minResolution: i3GEO.editorOL.minresolution
  767 + }
  768 +);
  769 +if(i3GEO.configura.locaplic === ""){
  770 + i3GEO.configura.locaplic = "../";
  771 +}
  772 +//faz a inclusao das camadas que possuem plugins
  773 +//veja o codigo PHP abaixo da funcao
  774 +//a variavel i3GEO.editorOL.layersIniciais ja contem a entrada para o layer
  775 +//mas vazia. Isso e necessario para incluir a camada na ordem correta
  776 +function adicionaPluginI3geo(camada,visivel,indice){
  777 + if(!camada.cache){
  778 + camada["cache"] = "NAO";
  779 + }
  780 + var n, i, l = i3GEO.pluginI3geo.layerMashup("openlayers",camada,"4326");
  781 + n = l.length;
  782 + for(i = 0; i < n; i++){
  783 +
  784 + if(l[i].displayInLayerSwitcher === true){
  785 + l[i].setVisibility(visivel);
  786 + }
  787 + if(l[i] != true){
  788 + i3GEO.editorOL.layersIniciais[indice] = l[i];
  789 + }
  790 + }
  791 +}
  792 +<?php
  793 + //camadas plugin
  794 + //cria o javascript que faz a inclusao das camadas
  795 + //configuradas com plugins do i3geo
  796 + //a variavel $temasPluginI3Geo e definida no inicio do PHP
  797 + foreach ($temasPluginI3Geo as $t){
  798 + //var_dump($temasPluginI3Geo);exit;
  799 + //cria um objeto javascript para iniciar o plugin
  800 + $camada = '{"ferramentas":'.$t["ferramentas"].',"tiles":"'.$t["tiles"].'","tema": "'.$t["tema"].'","name":"'.$t["name"].'","plugini3geo":'.$t["plugin"].',"cache":"'.$t["cache"].'","transitioneffect":"'.$t["transitioneffect"].'"}';
  801 + echo "var camada = $camada;\n";
  802 + //echo "i3GEO.pluginI3geo[camada.plugini3geo.plugin].openlayers.inicia(camada,i3GEO.editorOL.mapa);\n";
  803 + $visivel = "false";
  804 + if(in_array($t["name"],$visiveis)){
  805 + $visivel = "true";
  806 + }
  807 + echo "adicionaPluginI3geo(camada,".$visivel.",".$t["posicaoLayer"].");\n";
  808 + }
  809 +?>
  810 +i3GEO.editorOL.inicia();
  811 +</script>
  812 +</body>
  813 +</html>
... ...