/** * Title: Mapa de referência * * Cria e processa o mapa de referência * * Para modificar o mapa de referência, quando a opção for dinâmica, * edite o arquivo i3geo/aplicmap/referenciadinamica.map * * Namespace: * * i3GEO.maparef * * Exemplo: * * i3Geo.maparef.inicia() * * Veja: * * */ /** * Licença * * GPL2 * * i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet * * Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com * * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo sob os termos da Licença * Pública Geral GNU conforme publicada pela Free Software Foundation; * * Este programa é distribuído na expectativa de que seja útil, porém, SEM NENHUMA GARANTIA; nem mesmo a * garantia implícita de COMERCIABILIDADE OU ADEQUACÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença * Pública Geral do GNU para mais detalhes. Você deve ter recebido uma cópia da Licença Pública Geral do * GNU junto com este programa; se não, escreva para a Free Software Foundation, Inc., no endereço 59 Temple Street, Suite * 330, Boston, MA 02111-1307 USA. */ if (typeof (i3GEO) === 'undefined') { var i3GEO = {}; } i3GEO.maparef = { /** * Propriedade: fatorZoomDinamico * * Define o fator de zoom inicial do mapa de referência quando o modo dinamico for ativado * * Tipo: * * {numeric} * * Default: * * -3 */ fatorZoomDinamico : -3, /** * Propriedade: SELETORTIPO * * Inclui ou não o seletor de tipo de mapa de referência * * Tipo: * * {Boolean} * * Default: * * true */ SELETORTIPO : true, /** * Propriedade: VALORSELETORTIPO * * Valor inicial do seletor de tipo. Permite definir qual o tipo de mapa de referencia * * Tipo: * * {string} * * Valores: * * {mapa|dinamico} * * Default: * * dinamico */ VALORSELETORTIPO : "mapa", /** * Propriedade: PERMITEFECHAR * * Mostra o botão para fechar a janela ou não. * * Tipo: * * {boolean} * * Default: * * true */ PERMITEFECHAR : true, /** * Propriedade: PERMITEDESLOCAR * * Permite deslocar janela ou não. * * Tipo: * * {boolean} * * Default: * * true */ PERMITEDESLOCAR : true, /** * Propriedade: TRANSICAOSUAVE * * Altera a transparência quando o mouse sobrepõe ao mapa de referência e quando sai * * Essa opção como true não funciona bem no IE * * Tipo: * * {boolean} * * Default: * * false */ TRANSICAOSUAVE : false, /** * Propriedade: OPACIDADE * * Valor da transparência mínima utilizada quando TRANSICAOSUAVE for igual a true. * * Varia de 0 a 100 * * Tipo: * * {numeric} * * Default: * * 65 */ OPACIDADE : 65, /** * Propriedade: TOP * * Posição da janela em relação ao topo do mapa * * Tipo: * * {Numeric} * * Default: * * 4 */ TOP : 4, /** * Propriedade: RIGHT * * Posição da janela em relação ao lado direito do mapa * * Tipo: * * {Numeric} * * Defaul: * * 50 */ RIGHT : 70, W : function() { var w = parseInt(i3GEO.parametros.w, 10) / 5; if (w < 150) { w = 150; } return parseInt(w, 10); }, H : function() { var h = parseInt(i3GEO.parametros.h, 10) / 5; if (i3GEO.maparef.W() <= 150) { return 150; } else { return parseInt(h, 10); } }, /** * Function: inicia * * Inicializa o mapa de referência */ inicia : function() { if (typeof (console) !== 'undefined') console.info("i3GEO.maparef.inicia()"); var r, pos, novoel, ins, temp, moveX, moveY, escondeRef, janela; if ($i("i3geo_winRef")) { janela = YAHOO.i3GEO.janela.manager.find("i3geo_winRef"); janela.show(); janela.bringToTop(); return; } if (navm) { i3GEO.maparef.TRANSICAOSUAVE = false; } if (!$i("i3geo_winRef")) { novoel = document.createElement("div"); novoel.id = "i3geo_winRef"; novoel.style.display = "none"; novoel.style.borderColor = "gray"; ins = ""; if (this.PERMITEDESLOCAR) { ins += '
'; ins += ' "; if (this.SELETORTIPO) { ins += ""; } ins += "
"; } ins += '
'; ins += ''; ins += '
'; novoel.innerHTML = ins; if (i3GEO.maparef.TRANSICAOSUAVE) { YAHOO.util.Dom.setStyle(novoel, "opacity", i3GEO.maparef.OPACIDADE / 100); novoel.onmouseover = function() { YAHOO.util.Dom.setStyle(novoel, "opacity", 1); }; novoel.onmouseout = function() { YAHOO.util.Dom.setStyle(novoel, "opacity", i3GEO.maparef.OPACIDADE / 100); }; } document.body.appendChild(novoel); if ($i("refDinamico")) { $i("refDinamico").value = i3GEO.maparef.VALORSELETORTIPO; } } if ($i("i3geo_winRef").style.display !== "block") { $i("i3geo_winRef").style.display = "block"; this.PERMITEDESLOCAR ? temp = "shadow" : temp = "none"; janela = new YAHOO.widget.Panel("i3geo_winRef", { height : i3GEO.maparef.H() + 27 + "px", width : i3GEO.maparef.W() + 6 + "px", fixedcenter : false, constraintoviewport : false, underlay : temp, close : i3GEO.maparef.PERMITEFECHAR, visible : true, draggable : i3GEO.maparef.PERMITEDESLOCAR, modal : false, iframe : false }); YAHOO.i3GEO.janela.manager.register(janela); if (i3GEO.maparef.TRANSICAOSUAVE) { janela.cfg.setProperty("effect", [ { effect : YAHOO.widget.ContainerEffect.FADE, duration : 0.5 } ]); } janela.render(); janela.show(); try { janela.header.style.height = "20px"; } catch (e) { } ; r = $i("i3geo_winRef_c"); if (r) { // r.style.clip = "rect(0px, 160px, 185px, 0px)"; r.style.position = "absolute"; } pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO)); $i("mapaReferencia").style.height = i3GEO.maparef.H() + "px"; $i("i3geo_winRef").style.border = "0px solid gray"; moveX = pos[0] + i3GEO.parametros.w - i3GEO.maparef.W() + 3 - i3GEO.maparef.RIGHT; moveY = pos[1] + i3GEO.maparef.TOP; if (i3GEO.Interface.ATUAL === "googlemaps") { moveY += 30; } janela.moveTo(moveX, moveY); escondeRef = function() { YAHOO.util.Event.removeListener(janela.close, "click"); $i("imagemReferencia").src = ""; janela.destroy(); i3GEO.util.insereCookie("i3GEO.configura.mapaRefDisplay", "none"); }; YAHOO.util.Event.addListener(janela.close, "click", escondeRef); i3GEO.util.insereCookie("i3GEO.configura.mapaRefDisplay", "block"); if ($i("localizarxygeoProjxg")) { var temp = function() { i3GEO.coordenadas.atualizaGeo(objposicaocursor.dmsx, objposicaocursor.dmsy, "localizarxygeoProj"); }; YAHOO.util.Event.addListener($i("imagemReferencia"), "mousemove", temp); } } i3GEO.eventos.adicionaEventos("NAVEGAMAPA",["i3GEO.maparef.atualiza()"]); this.atualiza(true); $i("i3geo_winRef_h").className = "hd2"; if (navm) { $i("i3geo_winRef_h").style.width = i3GEO.maparef.W() + 6 + "px"; } }, /** * Function: atualiza * * Atualiza o mapa de referência. * * Se o modo cgi estiver ativado, o mapa de referência é desenhado utilizando-se como src da imagem o programa cgi do * Mapserver. * * No modo dinamico, a imagem é gerada de forma diferenciada. Nesse caso, o modo cgi é desabilitado. * * O atualizaReferencia é sempre chamado após o mapa ser redesenhado. * * Se houve alteração na extensão, é preciso refazer o mapa de referência se não, a imagem * atual é armazenada no quado de animação */ atualiza : function(forca) { if (arguments.length === 0) { forca = false; } if (typeof (console) !== 'undefined') console.info("i3GEO.maparef.atualiza()"); var tiporef, temp; temp = $i("refDinamico") ? tiporef = $i("refDinamico").value : tiporef = "fixo"; if ($i("mapaReferencia")) { temp = $i("maparefmaismenosZoom"); if (tiporef === "dinamico") { i3GEO.php.referenciadinamica( i3GEO.maparef.processaImagem, i3GEO.maparef.fatorZoomDinamico, tiporef, i3GEO.maparef.W(), i3GEO.maparef.H()); if (temp) { temp.style.display = "inline"; } } if (tiporef === "mapa") { i3GEO.php.referenciadinamica( i3GEO.maparef.processaImagem, i3GEO.maparef.fatorZoomDinamico, tiporef, i3GEO.maparef.W(), i3GEO.maparef.H()); if (temp) { temp.style.display = "inline"; } } } else { i3GEO.eventos.removeEventos("NAVEGAMAPA",["i3GEO.maparef.atualiza()"]); } }, /** * Substituí a imagem do mapa de referência pela última gerada. * * Esta função processa os dados de uma chamada AJAX para atualizar o mapa de referência * * Parametro: * * retorno - string no formato "var refimagem='nome da imagem'". */ processaImagem : function(retorno) { if (typeof (console) !== 'undefined') console.info("i3GEO.maparef.processaImagem()"); var m, box, temp, tiporef = "fixo"; // i3GEO.janela.fechaAguarde("ajaxreferencia1"); if ((retorno.data !== "erro") && (retorno.data !== undefined)) { eval(retorno.data); i3GEO.parametros.celularef = g_celularef; i3GEO.parametros.extentref = extentref; temp = $i("imagemReferencia"); if (temp) { m = new Image(); m.src = refimagem; temp.src = m.src; } temp = $i("refDinamico"); if (temp) { tiporef = temp.value; } if (tiporef !== "fixo") { box = $i("boxref"); if (box) { box.style.display = "none"; } return; } i3GEO.maparef.atualizaBox(); } }, /** * Atualiza o tamanho e a posição do box que indica a extensão geográfica do mapa atual * * O box é um div com id = "boxref". * */ atualizaBox : function() { var box = i3GEO.maparef.criaBox(), w; // // aplica ao box um novo tamanho // i3GEO.calculo.ext2rect( "boxref", i3GEO.parametros.extentref, i3GEO.parametros.mapexten, i3GEO.parametros.celularef, $i("mapaReferencia")); w = parseInt(box.style.width, 10); if (w > 120) { box.style.display = "none"; return; } box.style.display = "block"; box.style.top = parseInt(box.style.top, 10) + 4 + "px"; box.style.left = parseInt(box.style.left, 10) + 4 + "px"; if (w < 3) { box.style.width = "3px"; box.style.height = "3px"; } }, criaBox : function() { var box = $i("boxref"); if (!box) { novoel = document.createElement("div"); novoel.id = "boxref"; novoel.style.zIndex = 10; novoel.style.position = 'absolute'; novoel.style.cursor = "move"; novoel.style.backgroundColor = "RGB(120,220,220)"; novoel.style.borderWidth = "3px"; if (navm) { novoel.style.filter = 'alpha(opacity=40)'; } else { novoel.style.opacity = 0.4; } $i("mapaReferencia").appendChild(novoel); // // aplica os eventos de movimentação sobre o box azul // boxrefdd = new YAHOO.util.DD("boxref"); // // atualiza o mapa principal quando o box é modificado manualmente // novoel.onmouseup = function() { var rect, telaminx, telamaxx, telaminy, m, x, ext; rect = $i("boxref"); telaminx = parseInt(rect.style.left, 10); telamaxy = parseInt(rect.style.top, 10); telamaxx = telaminx + parseInt(rect.style.width, 10); telaminy = telamaxy + parseInt(rect.style.height, 10); m = i3GEO.calculo.tela2dd( telaminx, telaminy, i3GEO.parametros.celularef, i3GEO.parametros.extentref, "imagemReferencia"); x = i3GEO.calculo.tela2dd( telamaxx, telamaxy, i3GEO.parametros.celularef, i3GEO.parametros.extentref, "imagemReferencia"); ext = m[0] + " " + m[1] + " " + x[0] + " " + x[1]; i3GEO.navega.zoomExt(i3GEO.configura.locaplic, i3GEO.configura.sid, "", ext); }; return novoel; } else { return box; } }, /** * Ocorre quando o usuário clica sobre o mapa de referência, deslocando o mapa principal */ click : function() { if (typeof (console) !== 'undefined') console.info("i3GEO.maparef.click()"); //FIXME nao funciona no OSM if (i3GEO.Interface.ATUAL === "openlayers" || i3GEO.Interface.ATUAL === "googlemaps") { i3GEO.Interface[i3GEO.Interface.ATUAL].pan2ponto(objposicaocursor.ddx, objposicaocursor.ddy); } } };