interface_compacto.js 53.3 KB
if(typeof(i3GEO)==='undefined'){var i3GEO={}}var i3GEOtouchesPosMapa="";var i3geoOL;i3GEO.Interface={TABLET:false,ALTTABLET:"",OUTPUTFORMAT:"AGG_Q",BARRABOTOESTOP:12,BARRABOTOESLEFT:3,BARRADEZOOMRIGHT:0,BARRADEZOOMTOP:20,BARRADEZOOMLEFT:10,ATUAL:"openlayers",IDCORPO:"openlayers",ATIVAMENUCONTEXTO:false,IDMAPA:"",STATUS:{atualizando:[],trocando:false,pan:false},atual2gm:{insereIcone:true,inicia:function(){i3GEO.Interface.STATUS.trocando=true;i3GEO.janela.ESTILOAGUARDE="normal";try{if(google){i3GEO.Interface.atual2gm.initemp()}}catch(e){i3GEO.util.scriptTag("http://www.google.com/jsapi?callback=i3GEO.Interface.atual2gm.loadMaps","","",false)}},loadMaps:function(){google.load("maps","3",{callback:"i3GEO.Interface.atual2gm.initemp",other_params:"sensor=false"})},initemp:function(){var temp=function(){$i(i3GEO.Interface.IDCORPO).innerHTML="";i3GEO.Interface.ATUAL="googlemaps";i3GEO.Interface.cria(i3GEO.parametros.w,i3GEO.parametros.h);i3GEO.Interface.googlemaps.inicia();i3GEO.janela.fechaAguarde("googleMapsAguarde");i3GEO.arvoreDeCamadas.CAMADAS=[];i3GEO.atualiza();if(i3GEO.Interface.atual2gm.insereIcone===true){i3GEO.mapa.insereDobraPagina("openlayers",i3GEO.configura.locaplic+"/imagens/dobraopenlayers.png")}};i3GEO.php.converte2googlemaps(temp)}},atual2ol:{insereIcone:true,inicia:function(){i3GEO.Interface.STATUS.trocando=true;i3GEO.janela.ESTILOAGUARDE="normal";try{if(OpenLayers){i3GEO.Interface.atual2ol.initemp()}}catch(e){i3GEO.util.scriptTag(i3GEO.configura.locaplic+"/pacotes/openlayers/OpenLayers2131.js.php","i3GEO.Interface.atual2ol.initemp()","",false)}},initemp:function(){i3GEO.Interface.openlayers.fundoDefault();var temp=function(){OpenLayers.ImgPath="../pacotes/openlayers/img/";$i(i3GEO.Interface.IDCORPO).innerHTML="";i3GEO.Interface.ATUAL="openlayers";i3GEO.Interface.cria(i3GEO.parametros.w,i3GEO.parametros.h);i3GEO.Interface.openlayers.inicia();i3GEO.janela.fechaAguarde("OpenLayersAguarde");i3GEO.arvoreDeCamadas.CAMADAS=[];i3GEO.atualiza();if(i3GEO.Interface.atual2ol.insereIcone===true){i3GEO.mapa.insereDobraPagina("googlemaps",i3GEO.configura.locaplic+"/imagens/dobragooglemaps.png")}i3GEO.Interface.openlayers.zoom2ext(i3GEO.parametros.mapexten)};i3GEO.php.converte2openlayers(temp)}},aposAdicNovaCamada:function(camada){i3GEO.tema.ativaFerramentas(camada)},redesenha:function(){i3GEO.Interface[i3GEO.Interface.ATUAL].redesenha()},aplicaOpacidade:function(opacidade,layer){i3GEO.Interface[i3GEO.Interface.ATUAL].aplicaOpacidade(opacidade,layer)},atualizaMapa:function(){switch(i3GEO.Interface.ATUAL){case"openlayers":i3GEO.Interface.openlayers.atualizaMapa();break;default:i3GEO.Interface[i3GEO.Interface.ATUAL].redesenha()}},atualizaTema:function(retorno,tema){i3GEO.Interface[i3GEO.Interface.ATUAL].atualizaTema(retorno,tema)},ligaDesliga:function(obj){i3GEO.Interface[i3GEO.Interface.ATUAL].ligaDesliga(obj);if(obj.checked&&obj.value!=""){i3GEO.mapa.ativaTema(obj.value)}if(obj.value&&obj.value!=""){var ck=i3GEO.arvoreDeTemas.buscaCheckbox(obj.value);if(ck){ck.checked=obj.checked}}},adicionaKml:function(){if(i3GEO.Interface.ATUAL==="googlemaps"){i3GEO.Interface.googlemaps.adicionaKml("foo")}if(i3GEO.Interface.ATUAL==="openlayers"){i3GEO.Interface.openlayers.adicionaKml("foo")}},cria:function(w,h){i3GEO.Interface[i3GEO.Interface.ATUAL].cria(w,h)},inicia:function(w,h){var temp=window.location.href.split("?")[0],gadgets=i3GEO.gadgets;if($i("i3GEOcompartilhar")){i3GEO.social.compartilhar("i3GEOcompartilhar",temp,temp,"semtotal")}gadgets.mostraBuscaRapida();gadgets.mostraVersao();gadgets.mostraEmail();i3GEO.guias.cria();if($i("mst")){$i("mst").style.display="block"}i3GEO.navega.autoRedesenho.ativa();i3GEO.util.defineValor("i3geo_escalanum","value",i3GEO.parametros.mapscale);if((i3GEO.parametros.geoip==="nao")&&($i("ondeestou"))){$i("ondeestou").style.display="none"}i3GEO.Interface[i3GEO.Interface.ATUAL].inicia();if($i(i3GEO.login.divnomelogin)&&i3GEO.util.pegaCookie("i3geousuarionome")){$i(i3GEO.login.divnomelogin).innerHTML=i3GEO.util.pegaCookie("i3geousuarionome")}},alteraParametroLayers:function(parametro,valor){i3GEO.Interface[i3GEO.Interface.ATUAL].alteraParametroLayers(parametro,valor)},ativaBotoes:function(){if(i3GEO.Interface.STATUS.trocando===false){if(i3GEO.barraDeBotoes.TIPO==="olhodepeixe"||i3GEO.barraDeBotoes.TIPO==="olhodepeixe1"){i3GEO.barraDeBotoes.inicializaBarra()}else if(i3GEO.barraDeBotoes.TIPO==="yui"){i3GEO.Interface[i3GEO.Interface.ATUAL].ativaBotoes()}}},openlayers:{parametrosMap:{target:"openlayers",layers:[],controls:[],loadTilesWhileAnimating:true,loadTilesWhileInteracting:true},parametrosView:{},interacoes:[],FUNDOTEMA:"",TILES:true,GADGETS:{ZoomSlider:true,Zoom:true,ScaleLine:true,OverviewMap:false},SCALELINE:{},ZOOM:{},ZOOMSLIDER:{},MINEXTENT:[-0.0003,-0.0003,0.0003,0.0003],MAXEXTENT:[-180,-90,180,90],LAYERSADICIONAIS:[],LAYERFUNDO:"",googleLike:false,BALAOPROP:{removeAoAdicionar:true,classeCadeado:"i3GEOiconeAberto",autoPan:true,autoPanAnimation:{duration:250},minWidth:'200px',baloes:[]},balao:function(texto,completo,x,y,botaoMais,botaoProp){var icone,painel,b,cabecalho,conteudo,p=i3GEO.Interface.openlayers.BALAOPROP,removeBaloes;if(botaoMais===undefined){botaoMais=true}if(botaoProp===undefined){botaoProp=true}removeBaloes=function(){var t,n=i3GEO.Interface.openlayers.BALAOPROP.baloes.length,i;for(i=0;i<n;i++){t=i3GEO.Interface.openlayers.BALAOPROP.baloes[i];t.setPosition(undefined);t.getElement().parentNode.innerHTML=""}i3GEO.Interface.openlayers.BALAOPROP.baloes=[];return false};if(p.classeCadeado==="i3GEOiconeAberto"){removeBaloes()}if(i3GEO.eventos.cliquePerm.ativo===false){return}painel=document.createElement("div");painel.style.minWidth=p.minWidth;painel.className="ol-popup";cabecalho=document.createElement("div");cabecalho.className="i3GEOCabecalhoInfoWindow";icone=document.createElement("div");icone.className=p.classeCadeado;icone.onclick=function(){if(p.classeCadeado==="i3GEOiconeAberto"){p.classeCadeado="i3GEOiconeFechado"}else{p.classeCadeado="i3GEOiconeAberto"}this.className=p.classeCadeado;p.removeAoAdicionar=!p.removeAoAdicionar;return false};cabecalho.appendChild(icone);if(botaoProp===true){icone=document.createElement("div");icone.className="i3GEOiconeFerramentas";icone.style.left="3px";icone.onclick=function(){i3GEO.janela.prompt($trad("tolerancia"),function(){i3GEO.mapa.RESOLUCAOTIP=$i("i3GEOjanelaprompt").value},i3GEO.mapa.RESOLUCAOTIP);return false};cabecalho.appendChild(icone)}if(botaoMais===true){icone=document.createElement("div");icone.className="i3GEOiconeMais";icone.style.left="9px";icone.onclick=function(){i3GEO.janela.mensagemSimples("<div style='overflow:auto;height:100%'>"+completo+"</div>","");return false};cabecalho.appendChild(icone)}icone=document.createElement("div");icone.className="ol-popup-closer";icone.onclick=removeBaloes;cabecalho.appendChild(icone);painel.appendChild(cabecalho);conteudo=document.createElement("div");conteudo.innerHTML=texto;painel.appendChild(conteudo);b=new ol.Overlay({element:painel,stopEvent:true,autoPan:p.autoPan,autoPanAnimation:p.autoPanAnimation});p.baloes.push(b);i3geoOL.addOverlay(b);b.setPosition(i3GEO.util.projGeo2OSM(new ol.geom.Point([x,y])).getCoordinates())},redesenha:function(){var openlayers=i3GEO.Interface.openlayers;openlayers.criaLayers();openlayers.ordenaLayers();openlayers.recalcPar();i3GEO.janela.fechaAguarde()},fundoDefault:function(){var eng,oce,ims,wsm,tms,bra;eng=new ol.layer.Tile({title:"ESRI National Geographic",visible:true,isBaseLayer:true,name:"eng",source:new ol.source.TileArcGISRest({url:"http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",attributions:[new ol.Attribution({html:'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer">ArcGIS</a>'})]})});oce=new ol.layer.Tile({title:"ESRI Ocean Basemap",visible:false,isBaseLayer:true,name:"oce",source:new ol.source.TileArcGISRest({url:"http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer",attributions:[new ol.Attribution({html:'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer">ArcGIS</a>'})]})});ims=new ol.layer.Tile({title:"ESRI Imagery World 2D",visible:false,isBaseLayer:true,name:"ims",source:new ol.source.TileArcGISRest({url:"http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer",attributions:[new ol.Attribution({html:'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer">ArcGIS</a>'})]})});wsm=new ol.layer.Tile({title:"ESRI World Street Map",visible:false,isBaseLayer:true,name:"wsm",source:new ol.source.TileArcGISRest({url:"http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer",attributions:[new ol.Attribution({html:'Tiles &copy; <a href="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer">ArcGIS</a>'})]})});bra=new ol.layer.Tile({title:"Base carto MMA",visible:false,isBaseLayer:true,name:"bra",source:new ol.source.TileWMS({url:"http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/baseraster.map&",params:{'layers':"baseraster",'srs':"EPSG:4326",'format':"image/png"}})});tms=new ol.layer.Tile({title:"OSGEO",visible:false,isBaseLayer:true,name:"tms",source:new ol.source.TileWMS({url:"http://tilecache.osgeo.org/wms-c/Basic.py/",params:{'layers':"basic",'type':"png",'srs':"EPSG:4326",'format':"image/png",'VERSION':'1.1.1'},attributions:[new ol.Attribution({html:'&copy; <a href="http://www.tilecache.org/">2006-2010, TileCache Contributors</a>'})]})});i3GEO.Interface.openlayers.LAYERSADICIONAIS=[eng,oce,ims,wsm,tms,bra]},cria:function(w,h){var f,ins,i=$i(i3GEO.Interface.IDCORPO);if(i3GEO.Interface.openlayers.interacoes.length===0){i3GEO.Interface.openlayers.interacoes=[new ol.interaction.DoubleClickZoom(),new ol.interaction.KeyboardPan(),new ol.interaction.KeyboardZoom(),new ol.interaction.MouseWheelZoom(),new ol.interaction.PinchRotate(),new ol.interaction.PinchZoom(),new ol.interaction.DragZoom(),new ol.interaction.DragPan()]}if(i){f=$i("openlayers");if(!f){ins='<div id=openlayers style="display: block;position:relative;top: 0px; left: 0px;width:100%;height:100%;text-align:left;"></div>';i.innerHTML=ins}f=$i("openlayers");f.style.width="100%";f.style.height=h+"px"}i3GEO.Interface.IDMAPA="openlayers";if(i3GEO.Interface.openlayers.googleLike===false){i3GEO.Interface.openlayers.parametrosView.projection="EPSG:4326"}else{i3GEO.Interface.openlayers.parametrosView.projection="EPSG:3857"}i3GEO.Interface.openlayers.parametrosMap.view=new ol.View(i3GEO.Interface.openlayers.parametrosView);i3GEO.Interface.openlayers.parametrosMap.interactions=i3GEO.Interface.openlayers.interacoes;window.i3GEOcontrols={};var i3GEOcontrols=window.i3GEOcontrols;i3GEOcontrols.zoom=function(){var element=document.createElement('div');element.className='ol-i3GEOcontrols ol-control';var button=document.createElement('button');button.style.float="left";button.innerHTML="<img style='width:20px;' src='"+i3GEO.configura.locaplic+"/imagens/gisicons/projection.png' />";var zoom2ext=function(){i3GEO.Interface.openlayers.zoom2ext(i3GEO.parametros.extentTotal)};button.addEventListener('click',zoom2ext,false);element.appendChild(button);var button1=document.createElement('button');button1.style.float="left";button1.innerHTML="<img style='width:20px;' src='"+i3GEO.configura.locaplic+"/imagens/gisicons/zoom-region.png' />";var zoomli=function(){if(DetectaMobile("DetectMobileLong")){i3GEO.janela.tempoMsg($trad("x70"))}else{i3GEO.janela.tempoMsg($trad("x69"))}};button1.addEventListener('click',zoomli,false);element.appendChild(button1);element.appendChild(document.createElement('br'));var button3=document.createElement('button');button3.style.float="left";button3.innerHTML="<img style='width:16px;' src='"+i3GEO.configura.locaplic+"/imagens/oxygen/16x16/draw-triangle1.png' />";var anterior=function(){i3GEO.navega.extensaoAnterior()};button3.addEventListener('click',anterior,false);element.appendChild(button3);var button2=document.createElement('button');button2.style.float="left";button2.innerHTML="<img style='width:16px;' src='"+i3GEO.configura.locaplic+"/imagens/oxygen/16x16/draw-triangle2.png' />";var proximo=function(){i3GEO.navega.extensaoProximo()};button2.addEventListener('click',proximo,false);element.appendChild(button2);ol.control.Control.call(this,{element:element})};ol.inherits(i3GEOcontrols.zoom,ol.control.Control);i3GEO.Interface.openlayers.parametrosMap.controls=ol.control.defaults({attributionOptions:({collapsible:false})}).extend([new i3GEOcontrols.zoom()]);i3geoOL=new ol.Map(i3GEO.Interface.openlayers.parametrosMap);ol.layer.Layer.prototype.setVisibility=function(v){this.setVisible(v)};ol.layer.Layer.prototype.getVisibility=function(v){this.getVisible(v)};i3geoOL.panTo=function(x,y){this.getView().setCenter([x,y])};i3geoOL.getLayersByName=function(nome){var res=[],layers=this.getLayers(),n=layers.getLength(),i;for(i=0;i<n;i++){if(layers.item(i).get("name")&&layers.item(i).get("name")===nome){res.push(layers.item(i))}}return res};i3geoOL.addLayers=function(lista){var n=lista.length,i,lan,l;for(i=0;i<n;i++){if(lista[i].get!=undefined){lan=lista[i].get("name");if(lan){l=this.getLayersByName(lan);if(l.length===0){this.addLayer(lista[i])}}}}};i3geoOL.getLayersBase=function(){return i3geoOL.getLayersBy("isBaseLayer",true)};i3geoOL.getLayersBy=function(chave,valor){var res=[],layers=this.getLayers(),n=layers.getLength(),i;for(i=0;i<n;i++){if(layers.item(i).get(chave)&&layers.item(i).get(chave)===valor){res.push(layers.item(i))}}return res};i3geoOL.getControlsBy=function(chave,valor){var res=[],controles=this.getControls(),n=controles.getLength(),i;for(i=0;i<n;i++){if(controles.item(i).get(chave)&&controles.item(i).get(chave)===valor){res.push(controles.item(i))}}return res};i3geoOL.getCenter=function(){var c=this.getView().getCenter();return{"lon":c[0],"lat":c[1]}};i3geoOL.getZoom=function(){var c=this.getView().getZoom();return c};i3geoOL.getExtent=function(){var e=this.getView().calculateExtent(this.getSize());return{toBBOX:function(){return e.join(",")}}};i3geoOL.getScale=function(){var resolution,units,dpi,mpu,scale;resolution=this.getView().getResolution();units=this.getView().getProjection().getUnits();dpi=25.4/0.28;mpu=ol.proj.METERS_PER_UNIT[units];scale=resolution*mpu*39.37*dpi;return scale};i3geoOL.zoomToScale=function(escala){var resolution,units,dpi,mpu;units=this.getView().getProjection().getUnits();dpi=25.4/0.28;mpu=ol.proj.METERS_PER_UNIT[units];resolution=escala/(mpu*39.37*dpi);this.getView().setResolution(resolution)};i3geoOL.zoomToExtent=function(mapext){this.getView().fit(mapext,this.getSize())}},inicia:function(){if(i3GEO.Interface.openlayers.googleLike===true&&i3geoOL.getView().getProjection().getCode()!="EPSG:3857"){alert("Alerta! Projecao diferente da esperada. Veja i3geo/guia_de_migracao.txt")}var montaMapa=function(){var at,pz,temp,layers,i,texto,estilo,layersn,openlayers=i3GEO.Interface.openlayers;i3geoOL.updateSize();openlayers.registraEventos();openlayers.zoom2ext(i3GEO.parametros.mapexten);$i("openlayers").getElementsByClassName("ol-overlaycontainer-stopevent")[0].style.position="unset";if(openlayers.GADGETS.Zoom===true){pz=new ol.control.Zoom(openlayers.ZOOM);pz.setMap(i3geoOL)}if(openlayers.GADGETS.ZoomSlider===true&&i3GEO.parametros.h>600){pz=new ol.control.ZoomSlider(openlayers.ZOOMSLIDER);pz.setMap(i3geoOL)}if(openlayers.GADGETS.ScaleLine===true&&i3GEO.parametros.h>600){pz=new ol.control.ScaleLine(openlayers.SCALELINE);pz.setMap(i3geoOL)}at=new ol.control.Attribution({collapsible:false});at.setMap(i3geoOL);openlayers.criaLayers();temp=$i("listaLayersBase");if(temp&&i3GEO.arvoreDeCamadas.INCLUILFUNDO===false){i3GEO.arvoreDeCamadas.INCLUILFUNDO=false;estilo="cursor:pointer;vertical-align:top;padding-top:5px;";if(navm){estilo="border:0px solid white;cursor:pointer;vertical-align:middle;padding-top:0px;"}temp={"propriedades":[]};layers=i3geoOL.getLayersBy("isBaseLayer",true);layersn=layers.length;for(i=0;i<layersn;i++){texto="<input type=radio style='"+estilo+"' onclick='i3GEO.Interface.openlayers.ativaFundo(this.value)' name=i3GEObaseLayer value='"+layers[i].name+"' />"+layers[i].name;temp.propriedades.push({text:texto,url:""})}i3GEO.util.arvore("<b>"+$trad("p16")+"</b>","listaLayersBase",temp)}if(i3GEO.configura.mapaRefDisplay!=="none"){if(i3GEO.util.pegaCookie("i3GEO.configura.mapaRefDisplay")){i3GEO.configura.mapaRefDisplay=i3GEO.util.pegaCookie("i3GEO.configura.mapaRefDisplay")}if(i3GEO.configura.mapaRefDisplay==="block"){i3GEO.maparef.inicia()}}if(i3GEO.Interface.openlayers.googleLike===true){i3GEO.barraDeBotoes.INCLUIBOTAO.lentei=false}};if(i3GEO.arvoreDeCamadas.ATIVATEMA===""){i3GEO.arvoreDeCamadas.ATIVATEMA="i3GEO.Interface.ligaDesliga(this);i3GEO.eventos.executaEventos(i3GEO.eventos.ATUALIZAARVORECAMADAS);"}montaMapa();i3GEO.coordenadas.mostraCoordenadas();i3GEO.gadgets.mostraMenuSuspenso();i3GEO.ajuda.ativaLetreiro(i3GEO.parametros.mensagens);i3GEO.idioma.mostraSeletor();i3GEO.gadgets.mostraEscalaNumerica();i3GEO.util.arvore("<b>"+$trad("p13")+"</b>","listaPropriedades",i3GEO.configura.listaDePropriedadesDoMapa);i3GEO.gadgets.mostraMenuLista();i3GEO.arvoreDeCamadas.cria("",i3GEO.arvoreDeCamadas.CAMADAS,i3GEO.configura.sid,i3GEO.configura.locaplic);if(i3GEO.arvoreDeCamadas.MOSTRALISTAKML===true){i3GEO.Interface.openlayers.adicionaListaKml()}if(i3GEO.parametros.kmlurl!==""){i3GEO.Interface.openlayers.adicionaKml(true,i3GEO.parametros.kmlurl)}if($i("mst")){$i("mst").style.visibility="visible"}i3GEO.Interface.ativaBotoes();if(YAHOO.lang.isFunction(i3GEO.finalizaAPI)){i3GEO.finalizaAPI.call()}else{if(i3GEO.finalizaAPI!=""){eval(i3GEO.finalizaAPI)}}i3GEO.configura.iniciaFerramentas.executa()},aplicaOpacidade:function(opacidade,layer){var nlayers=i3GEO.arvoreDeCamadas.CAMADAS.length,l,i,camada;if(!layer){layer=""}for(i=nlayers-1;i>=0;i--){camada=i3GEO.arvoreDeCamadas.CAMADAS[i];l=i3geoOL.getLayersByName(camada.name)[0];if(l&&l.get("isBaseLayer")===false){if(layer==""||layer==camada.name){l.setOpacity(opacidade)}}}},adicionaListaKml:function(){var monta=function(retorno){var raiz,nraiz,i;raiz=retorno.data.canais;nraiz=raiz.length;for(i=0;i<nraiz;i++){i3GEO.Interface.openlayers.adicionaKml(false,raiz[i].link,raiz[i].title,false)}};i3GEO.php.listaRSSwsARRAY(monta,"KML")},adicionaKml:function(pan,url,titulo,ativo){var ngeoxml,i;if(!$i("arvoreCamadasKml")){i3GEO.Interface.openlayers.criaArvoreKML()}ngeoxml="geoXml_"+i3GEO.mapa.GEOXML.length;if(arguments.length===1){i=$i("i3geo_urlkml");if(i){url=i.value}else{url=""}titulo=ngeoxml;ativo=true}if(arguments.length===2){titulo=ngeoxml;ativo=true}if(url===""){return}i3GEO.mapa.GEOXML.push(ngeoxml);if(i3GEO.arvoreDeCamadas.MOSTRALISTAKML===false){i3GEO.arvoreDeCamadas.MOSTRALISTAKML=true;i3GEO.Interface.openlayers.criaArvoreKML()}i3GEO.Interface.openlayers.adicionaNoArvoreKml(url,titulo,ativo,ngeoxml)},criaArvoreKML:function(){var arvore,a,root,titulo,d,node;arvore=$i("arvoreCamadasKml");if(!arvore){d=document.createElement("div");d.id="arvoreCamadasKml";d.style.top="40px";a=$i(i3GEO.arvoreDeCamadas.IDHTML);if(a){a.parentNode.appendChild(d)}else{return}}i3GEO.Interface.openlayers.ARVORE=new YAHOO.widget.TreeView("arvoreCamadasKml");root=i3GEO.Interface.openlayers.ARVORE.getRoot();titulo="<table><tr><td><b>Kml</b></td></tr></table>";d={html:titulo,idkml:"raiz"};node=new YAHOO.widget.HTMLNode(d,root,true,true);node.enableHighlight=false;if(i3GEO.parametros.editor==="sim"){d=new YAHOO.widget.HTMLNode({html:"<a style='color:red' title='op&ccedil;&atilde;o vis&iacute;vel apenas para editores' href='../admin/html/webservices.html' target=blank >Editar cadastro</a>",idmenu:"",enableHighlight:false,expanded:false},node)}},adicionaNoArvoreKml:function(url,nomeOverlay,ativo,id){var node,d,nodekml;if(!$i("arvoreCamadasKml")){i3GEO.Interface.openlayers.criaArvoreKML()}if(arguments.length===2){ativo=true;id=nomeOverlay}if(arguments.length===2){id=nomeOverlay}node=i3GEO.Interface.openlayers.ARVORE.getNodeByProperty("idkml","raiz");html="<input onclick='i3GEO.Interface.openlayers.ativaDesativaCamadaKml(this,\""+url+"\")' class=inputsb style='cursor:pointer;' type='checkbox' value='"+id+"'";if(ativo===true){html+=" checked "}html+="/>";if(navm){estilo="cursor:default;vertical-align:35%;padding-top:0px;"}else{estilo="cursor:default;vertical-align:top;"}html+="&nbsp;<span style='"+estilo+"'>"+nomeOverlay+"</span>";d={html:html};nodekml=new YAHOO.widget.HTMLNode(d,node,true,true);nodekml.enableHighlight=false;nodekml.isleaf=true;i3GEO.Interface.openlayers.ARVORE.draw();i3GEO.Interface.openlayers.ARVORE.collapseAll();node.expand();if(ativo===true){i3GEO.Interface.openlayers.insereLayerKml(id,url)}},insereLayerKml:function(id,url){var l,temp;url=i3GEO.configura.locaplic+"/classesphp/proxy.php?url="+url;l=new ol.layer.Vector({title:url,name:id,isBaseLayer:false,source:new ol.source.Vector({url:url,format:new ol.format.KML({extractStyles:true}),tipoServico:"kml"})});i3geoOL.addLayer(l);temp=function(pixel){var feature,chaves,c,i=0,html="",prop,g;feature=i3geoOL.forEachFeatureAtPixel(pixel,function(feature,layer){return feature});if(feature){i3GEO.Interface.openlayers.BALAOPROP.removeAoAdicionar=false;i3GEO.Interface.openlayers.BALAOPROP.classeCadeado="i3GEOiconeFechado";chaves=feature.getKeys();prop=feature.getProperties();c=chaves.length;for(i=0;i<c;i++){if(chaves[i]!="geometry"&&chaves[i]!="styleUrl"){html+=chaves[i]+": "+prop[chaves[i]]}}g=feature.getGeometry().getCoordinates();i3GEO.Interface.openlayers.balao(html,"",g[0],g[1],"kml")}};i3geoOL.on('click',function(evt){evt.stopPropagation();evt.preventDefault();if(evt.dragging){return}temp(i3geoOL.getEventPixel(evt.originalEvent))})},ativaDesativaCamadaKml:function(obj,url){if(!obj.checked){i3geoOL.getLayersByName(obj.value)[0].setVisibility(false)}else{if(!(i3geoOL.getLayersByName(obj.value)[0])){i3GEO.Interface.openlayers.insereLayerKml(obj.value,url)}else{i3geoOL.getLayersByName(obj.value)[0].setVisibility(true)}}},criaLayers:function(){var matrixIds,resolutions,size,z,projectionExtent,source,configura=i3GEO.configura,url,nlayers=i3GEO.arvoreDeCamadas.CAMADAS.length,layer,camada,urllayer,opcoes,i,temp;temp=$i("i3GEOprogressoDiv");if(temp){i3GEO.Interface.STATUS.atualizando=[];temp.style.display="none"}if(i3GEO.Interface.openlayers.googleLike===true){url=configura.locaplic+"/classesphp/mapa_googlemaps.php?";projectionExtent=ol.proj.get('EPSG:3857').getExtent()}else{url=configura.locaplic+"/classesphp/mapa_openlayers.php?";projectionExtent=ol.proj.get('EPSG:4326').getExtent()}url+="g_sid="+i3GEO.configura.sid+"&TIPOIMAGEM="+configura.tipoimagem;size=ol.extent.getWidth(projectionExtent)/256;resolutions=new Array(40);matrixIds=new Array(40);for(z=0;z<40;++z){resolutions[z]=size/Math.pow(2,z);matrixIds[z]=z}$i("openlayers").style.backgroundColor="rgb("+i3GEO.parametros.cordefundo+")";i3geoOL.addLayers(i3GEO.Interface.openlayers.LAYERSADICIONAIS);opcoes={gutter:0,isBaseLayer:false,opacity:1,visible:false,singleTile:!(i3GEO.Interface.openlayers.TILES),tilePixelRatio:1,preload:Infinity,projection:'EPSG:4326'};if(i3GEO.Interface.openlayers.googleLike===true){opcoes.projection='EPSG:3857'}for(i=nlayers-1;i>=0;i--){layer="";camada=i3GEO.arvoreDeCamadas.CAMADAS[i];opcoes.singleTile=!(i3GEO.Interface.openlayers.TILES);if(i3geoOL.getLayersByName(camada.name).length===0&&camada.name.toLowerCase()!="copyright"){if(camada.plugini3geo&&camada.plugini3geo!=""&&camada.plugini3geo.parametros!=undefined){i3GEO.pluginI3geo.inicia(camada);continue}else{try{temp=camada.transitioneffect==="nao"?opcoes.preload=0:opcoes.preload=Infinity;if(i3GEO.Interface.openlayers.googleLike===false&&camada.connectiontype===7&&camada.wmsurl!==""&&camada.usasld.toLowerCase()!="sim"){urllayer=camada.wmsurl;if(camada.wmstile==10){source=new ol.source.WMTS({url:urllayer,matrixSet:opcoes.projection,format:'image/png',projection:opcoes.projection,tileGrid:new ol.tilegrid.WMTS({origin:ol.extent.getTopLeft(projectionExtent),resolutions:resolutions,matrixIds:matrixIds}),wrapX:true});source.set("tipoServico","WMTS");opcoes.singleTile=false}else{source=new ol.source.TileWMS({url:urllayer,params:{'VERSION':'1.1.0'},projection:camada.wmssrs});source.set("tipoServico","ImageWMS");opcoes.singleTile=false}opcoes.title=camada.tema;opcoes.name=camada.name;opcoes.isBaseLayer=false;opcoes.visible=true}else{if(camada.tiles==="nao"||camada.escondido.toLowerCase()==="sim"||camada.connectiontype===10||(camada.type===0&&camada.cache==="nao")||camada.type===8){opcoes.singleTile=true}else{temp=camada.type===3?opcoes.singleTile=false:opcoes.singleTile=!(i3GEO.Interface.openlayers.TILES)}if(camada.tiles==="nao"){opcoes.singleTile=true}if(camada.tiles==="sim"||camada.cache==="sim"||(camada.cortepixels&&camada.cortepixels>0)){opcoes.singleTile=false}if(camada.cache){urllayer=url+"&cache="+camada.cache}else{urllayer=url+"&cache=nao"}urllayer+="&layer="+camada.name;if(opcoes.singleTile===true){source=new ol.source.ImageWMS({url:urllayer,params:{'LAYERS':camada.name,'VERSION':'1.1.0'},projection:opcoes.projection,ratio:1});source.set("tipoServico","ImageWMS")}else{if(i3GEO.Interface.openlayers.googleLike===false){source=new ol.source.WMTS({url:urllayer,matrixSet:opcoes.projection,format:'image/png',projection:opcoes.projection,tileGrid:new ol.tilegrid.WMTS({origin:ol.extent.getTopLeft(projectionExtent),resolutions:resolutions,matrixIds:matrixIds}),wrapX:true});source.set("tipoServico","WMTS")}else{source=new ol.source.XYZ({url:urllayer+"&X={x}&Y={y}&Z={z}",matrixSet:opcoes.projection,format:'image/png',projection:opcoes.projection,wrapX:true});source.set("tipoServico","WMTS")}}opcoes.title=camada.tema;opcoes.name=camada.name}source.set("name",camada.name);source.set("parametrosUrl",{par:""});opcoes.source=source;opcoes.isBaseLayer=false;opcoes.visible=true;if(i3GEO.arvoreDeCamadas.BARRAPROGRESSO===true){source.on('tileloadstart',function(event){i3GEO.Interface.openlayers.loadStartLayer(source.get("name"))});source.on('tileloadend',function(event){i3GEO.Interface.openlayers.loadStopLayer(source.get("name"))});source.on('tileloaderror',function(event){i3GEO.Interface.openlayers.loadStopLayer(source.get("name"))})}if(opcoes.singleTile===true){layer=new ol.layer.Image(opcoes)}else{layer=new ol.layer.Tile(opcoes)}}catch(e){}}if(layer&&layer!=""){if(camada.escondido.toLowerCase()==="sim"){layer.preload=0}i3geoOL.addLayer(layer);i3GEO.Interface.aposAdicNovaCamada(camada)}}else{layer=i3geoOL.getLayersByName(camada.name)[0]}if(layer&&layer!=""){temp=camada.status==0?layer.setVisible(false):layer.setVisible(true)}}if(i3GEO.parametros.copyright!=""&&!$i("i3GEOcopyright")){temp=document.createElement("div");temp.id="i3GEOcopyright";temp.innerHTML="<p class=paragrafo >"+i3GEO.parametros.copyright+"</p>";if($i(i3GEO.Interface.IDMAPA)){$i(i3GEO.Interface.IDMAPA).appendChild(temp)}}else if(i3GEO.parametros.copyright!=""&&$i("i3GEOcopyright")){$i("i3GEOcopyright").innerHTML=i3GEO.parametros.copyright}if(i3GEO.Interface.openlayers.LAYERFUNDO!=""){i3GEO.Interface.openlayers.ativaFundo(i3GEO.Interface.openlayers.LAYERFUNDO)}},sobeLayersGraficos:function(){},inverteModoTile:function(){if(i3GEO.Interface.openlayers.TILES===true){i3GEO.Interface.openlayers.TILES=false}else{i3GEO.Interface.openlayers.TILES=true}i3GEO.Interface.openlayers.removeTodosOsLayers();i3GEO.Interface.openlayers.criaLayers()},removeTodosOsLayers:function(){var nlayers=i3GEO.arvoreDeCamadas.CAMADAS.length,layer,i,camada;for(i=nlayers-1;i>=0;i--){camada=i3GEO.arvoreDeCamadas.CAMADAS[i];layer=i3geoOL.getLayersByName(camada.name)[0];if(layer){i3geoOL.removeLayer(layer,false);i3GEO.pluginI3geo.removeCamada(camada.name)}}},alteraParametroLayers:function(parametro,valor){var layer,layers=i3GEO.arvoreDeCamadas.CAMADAS,nlayers=layers.length,i,param,source,k,url="",n,j;for(i=0;i<nlayers;i+=1){layer=i3geoOL.getLayersByName(layers[i].name)[0];if(layer&&layer!=undefined&&layer.get("isBaseLayer")===false){url="";source=layer.getSource();param=source.getProperties().parametrosUrl;param[parametro]=valor;chaves=i3GEO.util.listaTodasChaves(param);n=chaves.length;for(j=0;j<n;j++){k=chaves[j];if(param[k]!=""&&k!="par"){url+="&"+k+"="+param[k]}}param.par=url;source.set("parametrosUrl",param)}}},loadStartLayer:function(name){var p=$i("i3GEOprogressoDiv");if($i("ArvoreTituloTema"+name)){i3GEO.Interface.STATUS.atualizando.push(name);if(i3GEO.Interface.openlayers.FUNDOTEMA!=""){YAHOO.util.Dom.setStyle("ArvoreTituloTema"+name,"background",i3GEO.Interface.openlayers.FUNDOTEMA)}if(p){p.style.display="block";i3GEO.arvoreDeCamadas.progressBar.set('maxValue',i3GEO.Interface.STATUS.atualizando.length);i3GEO.arvoreDeCamadas.progressBar.set('value',i3GEO.arvoreDeCamadas.progressBar.get('value')-1)}}},loadStopLayer:function(name){var p=$i("i3GEOprogressoDiv");i3GEO.Interface.STATUS.atualizando.remove(name);if($i("ArvoreTituloTema"+name)){if(i3GEO.Interface.openlayers.FUNDOTEMA!=""){YAHOO.util.Dom.setStyle("ArvoreTituloTema"+name,"background","")}if(p){p.style.display="block";if(i3GEO.Interface.STATUS.atualizando.length>0){i3GEO.arvoreDeCamadas.progressBar.set('value',i3GEO.arvoreDeCamadas.progressBar.get('value')+1)}else{i3GEO.arvoreDeCamadas.progressBar.set('value',0);p.style.display="none"}}}},ordenaLayers:function(){var ordem=i3GEO.arvoreDeCamadas.CAMADAS,nordem=ordem.length,layer,layers,i;layers=i3geoOL.getLayers();for(i=nordem-1;i>=0;i--){layer=i3geoOL.getLayersByName(ordem[i].name);layer=layer[0];if(layer){layers.remove(layer);layers.push(layer)}}},ligaDesliga:function(obj){var layers=i3geoOL.getLayersByName(obj.value),desligar="",ligar="",b;if(layers.length>0){layers[0].setVisibility(obj.checked);if(obj.checked===true){i3GEO.pluginI3geo.ligaCamada(obj.value)}else{i3GEO.pluginI3geo.desligaCamada(obj.value)}}if(obj.checked){ligar=obj.value;i3GEO.arvoreDeCamadas.alteraPropCamadas("status","2",obj.value)}else{desligar=obj.value;i3GEO.arvoreDeCamadas.alteraPropCamadas("status","0",obj.value)}b=new Image();b.src=i3GEO.configura.locaplic+"/classesphp/mapa_controle.php?funcao=ligatemasbeacon&desligar="+desligar+"&ligar="+ligar+"&adicionar=nao&g_sid="+i3GEO.configura.sid;b.onerror=function(){i3GEO.mapa.legendaHTML.atualiza()}},ativaFundo:function(nome){var baseLayers,n,i,t,ck=true;if($i("CK"+nome)){ck=!$i("CK"+nome).checked}baseLayers=i3geoOL.getLayersBase();n=baseLayers.length;i3GEO.Interface.openlayers.LAYERFUNDO="";for(i=0;i<n;i++){baseLayers[i].setVisible(false);t=$i("CK"+baseLayers[i].get("name"));if(t){t.checked=false}}for(i=0;i<n;i++){if(baseLayers[i].get("name")===nome){baseLayers[i].setVisible(!ck);if(!ck===true){$i("CK"+nome).checked=true;i3GEO.Interface.openlayers.LAYERFUNDO=nome}}}},atualizaMapa:function(){var camadas=i3GEO.arvoreDeCamadas.CAMADAS,n=camadas.length,i;for(i=0;i<n;i++){i3GEO.Interface.openlayers.atualizaTema("",camadas[i].name)}},atualizaTema:function(retorno,tema){var layer=i3geoOL.getLayersByName(tema),objtemas,funcaoLoad,servico,source;if(layer.length==0){return""}else{layer=layer[0]}if(layer&&layer!=undefined){source=layer.getSource();servico=source.getProperties().tipoServico;if(servico==="WMTS"){funcaoLoad=source.getTileUrlFunction();if(funcaoLoad){layer.getSource().setTileUrlFunction(function(){var url=funcaoLoad.apply(this,arguments);url=url.replace("&cache=sim","&cache=nao");return url.split('&r=')[0]+'&r='+Math.random()+source.getProperties().parametrosUrl.par})}}if(servico==="ImageWMS"){funcaoLoad=source.getImageLoadFunction();if(funcaoLoad){layer.getSource().setImageLoadFunction(function(image,src){src=src.replace("&cache=sim","&cache=nao");src=src.split('&r=')[0]+'&r='+Math.random();image.getImage().src=src+source.getProperties().parametrosUrl.par})}}}if(retorno===""){return}objtemas=i3GEO.arvoreDeCamadas.converteChaveValor2normal(retorno.data.temas);i3GEO.Interface.openlayers.recalcPar();try{i3GEO.arvoreDeCamadas.atualiza(objtemas)}catch(e){i3GEO.arvoreDeCamadas.atualiza()}i3GEO.janela.fechaAguarde()},registraEventos:function(){i3GEOtouchesPosMapa="";var modoAtual="";i3GEO.eventos.ativa(i3geoOL.getTargetElement());i3geoOL.on("pointerdrag",function(e){i3GEO.Interface.STATUS.pan=true;modoAtual="move";i3GEO.barraDeBotoes.BOTAOCLICADO="pan";if(i3GEO.configura.mostraCentroDoMapa===true&&$i("localizarxygeoProjxg")){i3GEO.navega.marcaCentroDoMapa(i3GEO.navega.centroDoMapa())}});i3geoOL.on("click",function(e){e.stopPropagation();e.preventDefault()});i3geoOL.on("moveend",function(e){if(e.changedTouches){return}var xy;modoAtual="";i3GEO.Interface.openlayers.recalcPar();i3GEO.Interface.STATUS.pan=false;i3GEO.eventos.navegaMapa();i3GEO.util.escondePin();xy=i3GEO.navega.centroDoMapa();xy=i3GEO.calculo.dd2dms(xy[0],xy[1]);i3GEO.coordenadas.atualizaGeo(xy[0],xy[1],"localizarxygeoProj");i3GEO.eventos.cliquePerm.status=false;i3GEO.navega.registraExt(i3GEO.parametros.mapexten);i3GEO.Interface.STATUS.pan=false});i3geoOL.on("pointermove",function(e){if(modoAtual==="move"){return}var lonlat=false,d,pos="";lonlat=e.coordinate;if(i3GEO.Interface.openlayers.googleLike===true){lonlat=ol.proj.transform(lonlat,'EPSG:3857','EPSG:4326')}d=i3GEO.calculo.dd2dms(lonlat[0],lonlat[1]);objposicaocursor.ddx=lonlat[0];objposicaocursor.ddy=lonlat[1];objposicaocursor.dmsx=d[0];objposicaocursor.dmsy=d[1];objposicaocursor.imgx=e.pixel[0];objposicaocursor.imgy=e.pixel[1];objposicaocursor.telax=e.pixel[0]+pos[0];objposicaocursor.telay=e.pixel[1]+pos[1]});i3geoOL.on("touchend",function(e){e.preventDefault();calcCoord(e);if(i3GEO.eventos.cliquePerm.status===true&&i3GEO.eventos.CONTATOUCH<10){i3GEO.eventos.mouseupMapa(e)}i3GEO.eventos.cliquePerm.status=true;i3GEO.eventos.CONTATOUCH=0;i3GEO.Interface.STATUS.pan=false})},ativaBotoes:function(){var imagemxy,x2=0,y2=0;imagemxy=i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO));if($i("barraDeBotoes2")||i3GEO.barraDeBotoes.AUTO===true){x2=imagemxy[0]+i3GEO.Interface.BARRABOTOESLEFT;y2=imagemxy[1]+i3GEO.Interface.BARRABOTOESTOP}if($i("barraDeBotoes2")||i3GEO.barraDeBotoes.AUTO===true){i3GEO.barraDeBotoes.inicializaBarra("barraDeBotoes2","i3geo_barra2",false,x2,y2)}i3GEO.barraDeBotoes.ativaBotoes()},recalcPar:function(){i3GEOtouchesPosMapa="";var bounds=i3geoOL.getExtent().toBBOX().split(","),escalaAtual=i3geoOL.getScale();if(i3GEO.parametros.mapscale!==escalaAtual){i3GEO.arvoreDeCamadas.atualizaFarol(escalaAtual)}i3GEO.parametros.mapexten=bounds[0]+" "+bounds[1]+" "+bounds[2]+" "+bounds[3];i3GEO.parametros.mapscale=escalaAtual;i3GEO.parametros.pixelsize=i3geoOL.getView().getResolution();i3GEO.gadgets.atualizaEscalaNumerica(parseInt(escalaAtual,10))},zoom2ext:function(ext){var m,v;ext=i3GEO.util.extGeo2OSM(ext);m=ext.split(" ");m=[parseInt(m[0],10),parseInt(m[1],10),parseInt(m[2],10),parseInt(m[3],10)];v=i3geoOL.getView();v.fit(m,i3geoOL.getSize());i3GEO.eventos.cliquePerm.status=true},pan2ponto:function(x,y){if(i3GEO.Interface.openlayers.googleLike===true){var metrica;if(x<180&&x>-180){metrica=ol.proj.transform([x,y],'EPSG:4326','EPSG:3857');x=metrica[0];y=metrica[1]}}i3geoOL.panTo(x,y)}},googlemaps:{ESTILOS:{'Red':[{featureType:'all',stylers:[{hue:'#ff0000'}]}],'Countries':[{featureType:'all',stylers:[{visibility:'off'}]},{featureType:'water',stylers:[{visibility:'on'},{lightness:-100}]}],'Night':[{featureType:'all',stylers:[{invert_lightness:'true'}]}],'Blue':[{featureType:'all',elementType:'geometry',stylers:[{hue:'#0000b0'},{invert_lightness:'true'},{saturation:-30}]}],'Greyscale':[{featureType:'all',stylers:[{saturation:-100},{gamma:0.50}]}],'No roads':[{featureType:'road',stylers:[{visibility:'off'}]}],'Mixed':[{featureType:'landscape',stylers:[{hue:'#00dd00'}]},{featureType:'road',stylers:[{hue:'#dd0000'}]},{featureType:'water',stylers:[{hue:'#000040'}]},{featureType:'poi.park',stylers:[{visibility:'off'}]},{featureType:'road.arterial',stylers:[{hue:'#ffff00'}]},{featureType:'road.local',stylers:[{visibility:'off'}]}],'Chilled':[{featureType:'road',elementType:'geometry',stylers:[{'visibility':'simplified'}]},{featureType:'road.arterial',stylers:[{hue:149},{saturation:-78},{lightness:0}]},{featureType:'road.highway',stylers:[{hue:-31},{saturation:-40},{lightness:2.8}]},{featureType:'poi',elementType:'label',stylers:[{'visibility':'off'}]},{featureType:'landscape',stylers:[{hue:163},{saturation:-26},{lightness:-1.1}]},{featureType:'transit',stylers:[{'visibility':'off'}]},{featureType:'water',stylers:[{hue:3},{saturation:-24.24},{lightness:-38.57}]}]},ESTILOPADRAO:"",MAPOPTIONS:{scaleControl:true,mapTypeControlOptions:{position:1}},OPACIDADE:0.8,TIPOMAPA:"terrain",ZOOMSCALE:[591657550,295828775,147914387,73957193,36978596,18489298,9244649,4622324,2311162,1155581,577790,288895,144447,72223,36111,18055,9027,4513,2256,1128],PARAMETROSLAYER:"&TIPOIMAGEM="+i3GEO.configura.tipoimagem,posfixo:0,BALAOPROP:{removeAoAdicionar:true,classeCadeado:"i3GEOiconeAberto",baloes:[]},removeBaloes:function(){var p=i3GEO.Interface.googlemaps.BALAOPROP.baloes,n=p.length,i;for(i=0;i<n;i++){p[i].close()}p=[]},balao:function(texto,completo,x,y){var temp,elem,b,c,p;if(x===null||y===null){return}p=i3GEO.Interface.googlemaps.BALAOPROP;if(p.removeAoAdicionar===true){i3GEO.Interface.googlemaps.removeBaloes()}temp=document.createElement("div");temp.className="i3GEOCabecalhoInfoWindow";temp.style.top="0px";elem=document.createElement("img");elem.src=i3GEO.configura.locaplic+"/imagens/branco.gif";elem.className=p.classeCadeado;elem.onclick=function(){if(p.classeCadeado==="i3GEOiconeAberto"){p.classeCadeado="i3GEOiconeFechado"}else{p.classeCadeado="i3GEOiconeAberto"}this.className=p.classeCadeado;p.removeAoAdicionar=!p.removeAoAdicionar};temp.appendChild(elem);elem=document.createElement("img");elem.src=i3GEO.configura.locaplic+"/imagens/branco.gif";elem.className="i3GEOiconeFerramentas";elem.style.marginLeft="5px";elem.onclick=function(){i3GEO.janela.prompt($trad("tolerancia"),function(){i3GEO.mapa.RESOLUCAOTIP=$i("i3GEOjanelaprompt").value},i3GEO.mapa.RESOLUCAOTIP)};temp.appendChild(elem);elem=document.createElement("img");elem.src=i3GEO.configura.locaplic+"/imagens/branco.gif";elem.className="i3GEOiconeMais";elem.style.marginLeft="7px";elem.onclick=function(){i3GEO.janela.mensagemSimples("<div style='overflow:auto;height:100%'>"+completo+"</div>","");return false};temp.appendChild(elem);c=document.createElement("div");c.innerHTML=texto;e=document.createElement("div");e.appendChild(temp);e.appendChild(c);b=new google.maps.InfoWindow({content:e,position:new google.maps.LatLng(y,x),pixelOffset:new google.maps.Size(0,-24)});b.open(i3GeoMap);p.baloes.push(b)},atualizaTema:function(retorno,tema){var indice=i3GEO.Interface.googlemaps.retornaIndiceLayer(tema),objtemas;i3GeoMap.overlayMapTypes.removeAt(indice);i3GEO.Interface.googlemaps.posfixo+=1;i3GEO.Interface.googlemaps.insereLayer(tema,indice);if(retorno===""){return}objtemas=i3GEO.arvoreDeCamadas.converteChaveValor2normal(retorno.data.temas);i3GEO.Interface.googlemaps.recalcPar();try{i3GEO.arvoreDeCamadas.atualiza(objtemas)}catch(e){i3GEO.arvoreDeCamadas.atualiza()}i3GEO.janela.fechaAguarde()},removeTodosLayers:function(){var nlayers=i3GEO.arvoreDeCamadas.CAMADAS.length,i,camada,indice;for(i=0;i<nlayers;i++){camada=i3GEO.arvoreDeCamadas.CAMADAS[i];indice=i3GEO.Interface.googlemaps.retornaIndiceLayer(camada.name);if(indice!==false){try{i3GeoMap.overlayMapTypes.removeAt(indice);i3GEO.pluginI3geo.removeCamada(camada.name)}catch(e){}}}},redesenha:function(){i3GEO.Interface.googlemaps.posfixo+=1;i3GEO.Interface.googlemaps.removeTodosLayers();i3GEO.Interface.googlemaps.criaLayers()},cria:function(w,h){var i,f,ins;google.maps.visualRefresh=true;posfixo="&nd=0";i=$i(i3GEO.Interface.IDCORPO);if(i){f=$i("googlemapsdiv");if(!f){ins='<div id=googlemapsdiv style="width:0px;height:0px;text-align:left;background-image:url('+i3GEO.configura.locaplic+'/imagens/i3geo1bw.jpg)"></div>';i.innerHTML=ins}f=$i("googlemapsdiv");if(w){f.style.width=w+"px";f.style.height=h+"px"}}i3GeoMap="";i3GEO.Interface.IDMAPA="googlemapsdiv";if(i3GEO.Interface.TABLET===false){i3GEO.barraDeBotoes.INCLUIBOTAO.zoomli=true;i3GEO.barraDeBotoes.INCLUIBOTAO.pan=true;i3GEO.barraDeBotoes.INCLUIBOTAO.zoomtot=true}},ativaZoomBox:function(){i3GeoMap.enableKeyDragZoom({key:'ctrl'})},inicia:function(){var pol,ret,montaMapa;pol=i3GEO.parametros.mapexten;ret=pol.split(" ");if($i("i3GEOprogressoDiv")){$i("i3GEOprogressoDiv").style.display="block"}montaMapa=function(retorno){var sw,ne,estilo,dobra=$i("i3GEOdobraPagina");if(i3GEO.Interface.googlemaps.ESTILOS&&i3GEO.Interface.googlemaps.ESTILOPADRAO!=""){i3GEO.Interface.googlemaps.MAPOPTIONS.mapTypeId=i3GEO.Interface.googlemaps.ESTILOPADRAO}if(i3GEO.Interface.BARRADEZOOMRIGHT!=0){i3GEO.Interface.googlemaps.MAPOPTIONS.zoomControlOptions={position:google.maps.ControlPosition.RIGHT_TOP};i3GEO.Interface.googlemaps.MAPOPTIONS.panControlOptions={position:google.maps.ControlPosition.RIGHT_TOP}}try{i3GeoMap=new google.maps.Map($i(i3GEO.Interface.IDMAPA),i3GEO.Interface.googlemaps.MAPOPTIONS)}catch(e){alert(e);return}if(i3GEO.Interface.googlemaps.ESTILOS&&i3GEO.Interface.googlemaps.ESTILOPADRAO!=""){estilo=i3GEO.Interface.googlemaps.ESTILOS[i3GEO.Interface.googlemaps.ESTILOPADRAO];i3GeoMap.mapTypes.set(i3GEO.Interface.googlemaps.ESTILOPADRAO,new google.maps.StyledMapType(estilo,{name:i3GEO.Interface.googlemaps.ESTILOPADRAO}))}else{i3GeoMap.setMapTypeId(i3GEO.Interface.googlemaps.TIPOMAPA)}if(dobra){$i(i3GEO.Interface.IDMAPA).appendChild(dobra)}if(!i3GEO.Interface.googlemaps.MAPOPTIONS.center&&!i3GEO.Interface.googlemaps.MAPOPTIONS.zoom){sw=new google.maps.LatLng(ret[1],ret[0]);ne=new google.maps.LatLng(ret[3],ret[2]);i3GeoMap.fitBounds(new google.maps.LatLngBounds(sw,ne))}if(!$i("keydragzoom_script")){js=i3GEO.configura.locaplic+"/pacotes/google/keydragzoom.js";i3GEO.util.scriptTag(js,"i3GEO.Interface.googlemaps.ativaZoomBox()","keydragzoom_script")}i3GeoMapOverlay=new google.maps.OverlayView();i3GeoMapOverlay.draw=function(){};i3GEO.Interface.googlemaps.criaLayers();i3GeoMapOverlay.setMap(i3GeoMap);i3GEO.Interface.googlemaps.registraEventos();if(i3GEO.Interface.STATUS.trocando===false){i3GEO.gadgets.mostraInserirKml()}i3GEO.eventos.ativa($i(i3GEO.Interface.IDMAPA));if(i3GEO.Interface.STATUS.trocando===false){i3GEO.coordenadas.mostraCoordenadas();i3GEO.gadgets.mostraEscalaNumerica();i3GEO.gadgets.mostraMenuLista();i3GEO.idioma.mostraSeletor()}i3GEO.gadgets.mostraMenuSuspenso();if(i3GEO.Interface.STATUS.trocando===true&&$i(i3GEO.arvoreDeCamadas.IDHTML)){$i(i3GEO.arvoreDeCamadas.IDHTML).innerHTML=""}if(i3GEO.Interface.STATUS.trocando===false){i3GEO.util.arvore("<b>"+$trad("p13")+"</b>","listaPropriedades",i3GEO.configura.listaDePropriedadesDoMapa)}if(i3GEO.arvoreDeCamadas.ATIVATEMA===""){i3GEO.arvoreDeCamadas.ATIVATEMA="i3GEO.Interface.ligaDesliga(this)"}i3GEO.arvoreDeCamadas.cria("",i3GEO.arvoreDeCamadas.CAMADAS,i3GEO.configura.sid,i3GEO.configura.locaplic);if(i3GEO.arvoreDeCamadas.MOSTRALISTAKML===true){i3GEO.Interface.googlemaps.adicionaListaKml()}if(i3GEO.parametros.kmlurl!==""){i3GEO.Interface.googlemaps.adicionaKml(true,i3GEO.parametros.kmlurl)}i3GEO.Interface.ativaBotoes();if(YAHOO.lang.isFunction(i3GEO.finalizaAPI)){i3GEO.finalizaAPI.call()}else{if(i3GEO.finalizaAPI!=""){eval(i3GEO.finalizaAPI)}}i3GEO.configura.iniciaFerramentas.executa();google.maps.event.addListenerOnce(i3GeoMap,'idle',function(){var z=i3GeoMap.getZoom();if(z!=undefined){i3GeoMap.setZoom(parseInt(z,10)+1)}})};i3GEO.php.googlemaps(montaMapa)},criaLayers:function(){var nlayers=i3GEO.arvoreDeCamadas.CAMADAS.length,i,camada,indice;for(i=0;i<nlayers;i++){camada=i3GEO.arvoreDeCamadas.CAMADAS[i];indice=i3GEO.Interface.googlemaps.retornaIndiceLayer(camada.name);if(!indice){if(camada.status!=0){if(camada.plugini3geo&&camada.plugini3geo!=""&&camada.plugini3geo.parametros!=undefined){i3GEO.pluginI3geo.inicia(camada);continue}else{i3GEO.Interface.googlemaps.insereLayer(camada.name,0,camada.cache)}}i3GEO.Interface.aposAdicNovaCamada(camada)}}i3GEO.Interface.googlemaps.recalcPar()},criaImageMap:function(nomeLayer,cache){var i3GEOTileO="";if(cache=="undefined"||cache==undefined){cache=""}i3GEOTileO=new google.maps.ImageMapType({getTileUrl:function(coord,zoom){var url=i3GEO.configura.locaplic+"/classesphp/mapa_googlemaps.php?g_sid="+i3GEO.configura.sid+"&cache="+cache+"&Z="+zoom+"&X="+coord.x+"&Y="+coord.y+"&layer="+nomeLayer+i3GEO.Interface.googlemaps.PARAMETROSLAYER+'&r='+Math.random();return url+'&nd='+i3GEO.Interface.googlemaps.posfixo},tileSize:new google.maps.Size(256,256),isPng:true,name:nomeLayer});return i3GEOTileO},bbox2mercator:function(bbox){var c=bbox.split(" "),p1,p2;p1=i3GEO.Interface.googlemaps.geo2mercator(c[0],c[1]);p2=i3GEO.Interface.googlemaps.geo2mercator(c[2],c[3]);return p1.x+" "+p1.y+" "+p2.x+" "+p2.y},geo2mercator:function(x,y){var source="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",dest="+title= Google Mercator EPSG:900913 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs",p=new Proj4js.Point(parseInt(x,10),parseInt(y,10));Proj4js.defs["WGS84"]=source;Proj4js.defs["EPSG:900913"]=dest;source=new Proj4js.Proj('WGS84');dest=new Proj4js.Proj('EPSG:900913');Proj4js.transform(source,dest,p);return p},insereLayer:function(nomeLayer,indice,cache){if(i3GEO.pluginI3geo.existeObjeto(nomeLayer)===false){var i=i3GEO.Interface.googlemaps.criaImageMap(nomeLayer,cache);i3GeoMap.overlayMapTypes.insertAt(indice,i)}},registraEventos:function(){i3GEOtouchesPosMapa="";modoAtual="";google.maps.event.addListener(i3GeoMap,"dragstart",function(){modoAtual="move";if(i3GEO.configura.mostraCentroDoMapa===true&&$i("localizarxygeoProjxg")){i3GEO.navega.marcaCentroDoMapa(i3GEO.navega.centroDoMapa())}i3GEO.eventos.cliquePerm.status=false});google.maps.event.addListener(i3GeoMap,"dragend",function(){var xy;i3GEO.Interface.googlemaps.recalcPar();i3GEO.eventos.navegaMapa();i3GEO.util.escondePin();xy=i3GEO.navega.centroDoMapa();xy=i3GEO.calculo.dd2dms(xy[0],xy[1]);i3GEO.coordenadas.atualizaGeo(xy[0],xy[1],"localizarxygeoProj");i3GEO.navega.registraExt(i3GEO.parametros.mapexten)});google.maps.event.addListener(i3GeoMap,"tilesloaded",function(){i3GEO.Interface.googlemaps.recalcPar();i3GEO.navega.registraExt(i3GEO.parametros.mapexten)});google.maps.event.addListener(i3GeoMap,"bounds_changed",function(){i3GEO.Interface.googlemaps.recalcPar();i3GEO.eventos.navegaMapa()});google.maps.event.addListener(i3GeoMap,"mousemove",function(ponto){if(i3GEOtouchesPosMapa===""){i3GEOtouchesPosMapa=i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDMAPA))}var teladms,tela,pos=i3GEOtouchesPosMapa;if(modoAtual==="move"){return}ponto=ponto.latLng;teladms=i3GEO.calculo.dd2dms(ponto.lng(),ponto.lat());tela=i3GeoMapOverlay.getProjection().fromLatLngToContainerPixel(ponto);objposicaocursor={ddx:ponto.lng(),ddy:ponto.lat(),dmsx:teladms[0],dmsy:teladms[1],imgx:tela.x,imgy:tela.y,telax:tela.x+pos[0],telay:tela.y+pos[1]}})},retornaIndiceLayer:function(nomeLayer){var i=false;try{i3GeoMap.overlayMapTypes.forEach(function(elemento,number){if(elemento.name===nomeLayer){i=number}});return i}catch(e){return false}},retornaObjetoLayer:function(nomeLayer){var i=false;try{i3GeoMap.overlayMapTypes.forEach(function(elemento,number){if(elemento.name===nomeLayer){i=elemento}});return i}catch(e){return false}},retornaDivLayer:function(nomeLayer){var i,divmapa=$i("googlemapsdiv"),divimg,n;divimg=divmapa.getElementsByTagName("img");n=divimg.length;if(divimg&&n>0){for(i=0;i<n;i++){if(divimg[i].src.search("&layer="+nomeLayer+"&")>0){return divimg[i].parentNode.parentNode.parentNode}}}return false},ligaDesliga:function(obj){var plugin,indice,temp,desligar="",ligar="",n,i,lista=[],listatemp;indice=i3GEO.Interface.googlemaps.retornaIndiceLayer(obj.value);temp=function(){i3GEO.mapa.legendaHTML.atualiza()};plugin=i3GEO.pluginI3geo.existeObjeto(obj.value);if(obj.checked&&(!indice||plugin===true)){ligar=obj.value;listatemp=i3GEO.arvoreDeCamadas.listaLigadosDesligados()[0];n=i3GEO.arvoreDeCamadas.CAMADAS.length;for(i=0;i<n;i++){if(i3GEO.util.in_array(i3GEO.arvoreDeCamadas.CAMADAS[i].name,listatemp)){lista.push(i3GEO.arvoreDeCamadas.CAMADAS[i].name)}}lista.reverse();if(plugin===false){n=lista.length;indice=0;for(i=0;i<n;i++){if(lista[i]==obj.value){indice=i}}i3GEO.Interface.googlemaps.insereLayer(obj.value,(indice))}else{i3GEO.pluginI3geo.ligaCamada(obj.value)}i3GEO.arvoreDeCamadas.alteraPropCamadas("status","2",obj.value)}else{if(plugin===true){desligar=obj.value;i3GEO.arvoreDeCamadas.alteraPropCamadas("status","0",obj.value);i3GEO.pluginI3geo.desligaCamada(obj.value)}else if(indice!==false){desligar=obj.value;i3GEO.arvoreDeCamadas.alteraPropCamadas("status","0",obj.value);i3GeoMap.overlayMapTypes.removeAt(indice)}}if(desligar!==""||ligar!==""){i3GEO.php.ligatemas(temp,desligar,ligar)}},bbox:function(){var bd,so,ne,bbox;bd=i3GeoMap.getBounds();so=bd.getSouthWest();ne=bd.getNorthEast();bbox=so.lng()+" "+so.lat()+" "+ne.lng()+" "+ne.lat();return(bbox)},ativaBotoes:function(){var imagemxy,x2=0,y2=0;imagemxy=i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO));if($i("barraDeBotoes2")||i3GEO.barraDeBotoes.AUTO===true){x2=imagemxy[0]+i3GEO.Interface.BARRABOTOESLEFT;y2=imagemxy[1]+i3GEO.Interface.BARRABOTOESTOP}if($i("barraDeBotoes2")||i3GEO.barraDeBotoes.AUTO===true){i3GEO.barraDeBotoes.inicializaBarra("barraDeBotoes2","i3geo_barra2",false,x2,y2)}i3GEO.barraDeBotoes.ativaBotoes()},aplicaOpacidade:function(opacidade,layer){var nlayers=i3GEO.arvoreDeCamadas.CAMADAS.length,i,camada,div;if(!layer){layer=""}for(i=0;i<nlayers;i++){camada=i3GEO.arvoreDeCamadas.CAMADAS[i];if(camada&&camada.name){div=i3GEO.Interface.googlemaps.retornaDivLayer(camada.name);if(div){if(layer==""||layer==camada.name){YAHOO.util.Dom.setStyle(div,"opacity",opacidade)}}}}},mudaOpacidade:function(valor){i3GEO.Interface.googlemaps.OPACIDADE=valor;i3GEO.Interface.googlemaps.redesenha()},recalcPar:function(){i3GEOtouchesPosMapa="";try{var sw,ne,escalaAtual=i3GEO.parametros.mapscale;sw=i3GeoMap.getBounds().getSouthWest();ne=i3GeoMap.getBounds().getNorthEast();i3GEO.parametros.mapexten=sw.lng()+" "+sw.lat()+" "+ne.lng()+" "+ne.lat();i3GEO.parametros.mapscale=i3GEO.Interface.googlemaps.calcescala();sw=i3GeoMapOverlay.getProjection().fromContainerPixelToLatLng(new google.maps.Point(0,1));ne=i3GeoMapOverlay.getProjection().fromContainerPixelToLatLng(new google.maps.Point(1,0));i3GEO.parametros.pixelsize=sw.lng()-ne.lng();if(i3GEO.parametros.pixelsize<0){i3GEO.parametros.pixelsize=i3GEO.parametros.pixelsize*-1}if(i3GEO.parametros.mapscale!==escalaAtual&&escalaAtual!==0){i3GEO.arvoreDeCamadas.atualizaFarol(i3GEO.parametros.mapscale)}}catch(e){i3GEO.parametros.mapexten="0 0 0 0";i3GEO.parametros.mapscale=0}},calcescala:function(){var zoom=i3GeoMap.getZoom();return(i3GEO.Interface.googlemaps.ZOOMSCALE[zoom])},escala2nzoom:function(escala){var n,i;n=i3GEO.Interface.googlemaps.ZOOMSCALE.length;for(i=0;i<n;i++){if(i3GEO.Interface.googlemaps.ZOOMSCALE[i]<escala){return(i)}}},zoom2extent:function(mapexten){var re=new RegExp(",","g"),pol=mapexten.replace(re," "),ret=pol.split(" "),sw=new google.maps.LatLng(ret[1],ret[0]),ne=new google.maps.LatLng(ret[3],ret[2]);i3GeoMap.fitBounds(new google.maps.LatLngBounds(sw,ne))},pan2ponto:function(x,y){i3GeoMap.panTo(new google.maps.LatLng(y,x))},adicionaKml:function(pan,url,titulo,ativo){var ngeoxml,i;if(!$i("arvoreCamadasKml")){i3GEO.Interface.googlemaps.criaArvoreKML()}ngeoxml="geoXml_"+i3GEO.mapa.GEOXML.length;if(arguments.length===1){i=$i("i3geo_urlkml");if(i){url=i.value}else{url=""}titulo=ngeoxml;ativo=true}if(arguments.length===2){titulo=ngeoxml;ativo=true}if(url===""){return}i3GEO.mapa.GEOXML.push(ngeoxml);if(i3GEO.arvoreDeCamadas.MOSTRALISTAKML===false){i3GEO.arvoreDeCamadas.MOSTRALISTAKML=true;i3GEO.Interface.googlemaps.criaArvoreKML()}i3GEO.Interface.googlemaps.adicionaNoArvoreGoogle(url,titulo,ativo,ngeoxml)},adicionaListaKml:function(){var monta=function(retorno){var raiz,nraiz,i;raiz=retorno.data.canais;nraiz=raiz.length;for(i=0;i<nraiz;i++){i3GEO.Interface.googlemaps.adicionaKml(false,raiz[i].link,raiz[i].title,false)}};i3GEO.php.listaRSSwsARRAY(monta,"KML")},adicionaNoArvoreGoogle:function(url,nomeOverlay,ativo,id){var node,d,nodekml;if(!$i("arvoreCamadasKml")){i3GEO.Interface.googlemaps.criaArvoreKML()}if(arguments.length===2){ativo=true;id=nomeOverlay}if(arguments.length===2){id=nomeOverlay}node=i3GEO.Interface.googlemaps.ARVORE.getNodeByProperty("idkml","raiz");html="<input onclick='i3GEO.Interface.googlemaps.ativaDesativaCamadaKml(this,\""+url+"\")' class=inputsb style='cursor:pointer;' type='checkbox' value='"+id+"'";if(ativo===true){html+=" checked "}html+="/>";if(navm){estilo="cursor:default;vertical-align:35%;padding-top:0px;"}else{estilo="cursor:default;vertical-align:top;"}html+="&nbsp;<span style='"+estilo+"'>"+nomeOverlay+"</span>";d={html:html};nodekml=new YAHOO.widget.HTMLNode(d,node,true,true);nodekml.enableHighlight=false;nodekml.isleaf=true;i3GEO.Interface.googlemaps.ARVORE.draw();i3GEO.Interface.googlemaps.ARVORE.collapseAll();node.expand();if(ativo===true){eval(id+" = new google.maps.KmlLayer('"+url+"',{map:i3GeoMap,preserveViewport:true});")}},criaArvoreKML:function(){var arvore,a,root,titulo,d,node;arvore=$i("arvoreCamadasKml");if(!arvore){d=document.createElement("div");d.id="arvoreCamadasKml";d.style.top="40px";a=$i(i3GEO.arvoreDeCamadas.IDHTML);if(a){a.parentNode.appendChild(d)}else{return}}i3GEO.Interface.googlemaps.ARVORE=new YAHOO.widget.TreeView("arvoreCamadasKml");root=i3GEO.Interface.googlemaps.ARVORE.getRoot();titulo="<table><tr><td><b>Kml</b></td></tr></table>";d={html:titulo,idkml:"raiz"};node=new YAHOO.widget.HTMLNode(d,root,true,true);node.enableHighlight=false;if(i3GEO.parametros.editor==="sim"){d=new YAHOO.widget.HTMLNode({html:"<a style='color:red' title='op&ccedil;&atilde;o vis&iacute;vel apenas para editores' href='../admin/html/webservices.html' target=blank >Editar cadastro</a>",idmenu:"",enableHighlight:false,expanded:false},node)}},ativaDesativaCamadaKml:function(obj,url){if(!obj.checked){eval(obj.value+".setMap(null);")}else{eval(obj.value+" = new google.maps.KmlLayer(url,{map:i3GeoMap,preserveViewport:true});")}},alteraParametroLayers:function(parametro,valor){parametro=parametro.toUpperCase();var reg=new RegExp(parametro+"([=])+([a-zA-Z0-9_]*)");i3GEO.Interface.googlemaps.PARAMETROSLAYER=i3GEO.Interface.googlemaps.PARAMETROSLAYER.replace(reg,"");i3GEO.Interface.googlemaps.PARAMETROSLAYER+="&"+parametro+"="+valor;i3GEO.Interface.googlemaps.redesenha()}}};