/** * 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 = {}; } //TODO incluir template para montagem do mapa 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: 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 : 120, //tipo de mapa que sera utilizado //wms: usa um wms definido em /aplicmap/referenciadinamica.map //map: utiliza o mapa atual //api: utiliza as fucoes da api em uso (implementado apenas para openlayers) DEFAULTMAP : "wms", //guarda o objeto criado pela api se for o caso APIOBJ : "", 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()"); if(i3GEO.maparef.DEFAULTMAP == "api" && i3GEO.Interface.ATUAL == "openlayers"){ if(i3GEO.maparef.APIOBJ == ""){ i3GEO.maparef.APIOBJ = new ol.control.OverviewMap({ collapsible: true, collapsed: false, layers: [i3geoOL.getLayerBase()], view: new ol.View( i3GEO.Interface.openlayers.parametrosView ) }); i3GEO.maparef.APIOBJ.setMap(i3geoOL); } else { i3GEO.maparef.APIOBJ.setCollapsed(!i3GEO.maparef.APIOBJ.getCollapsed()); if(i3GEO.maparef.APIOBJ.getCollapsed() == true){ i3GEO.maparef.APIOBJ.setMap(null); i3GEO.maparef.APIOBJ = ""; } } return; } else if (i3GEO.Interface.ATUAL == "googlemaps"){ i3GEO.Interface.ATUAL = "wms"; } 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 (!$i("i3geo_winRef")) { novoel = document.createElement("div"); novoel.id = "i3geo_winRef"; novoel.style.display = "none"; novoel.style.borderColor = "gray"; ins = ""; ins += '
'; ins += '
"; ins += '
'; ins += ''; ins += '
'; novoel.innerHTML = ins; $(novoel).css("opacity", 1); document.body.appendChild(novoel); } if ($i("i3geo_winRef").style.display !== "block") { $i("i3geo_winRef").style.display = "block"; janela = new YAHOO.widget.Panel("i3geo_winRef", { height : i3GEO.maparef.H() + 47 + "px", width : i3GEO.maparef.W() + 6 + "px", fixedcenter : false, constraintoviewport : false, underlay : "shadow", close : true, visible : true, draggable : true, modal : false, iframe : false, strings: {close: "cancel"} }); YAHOO.i3GEO.janela.manager.register(janela); janela.cfg.setProperty("effect", [ { effect : YAHOO.widget.ContainerEffect.FADE, duration : 0.5 } ]); janela.render(); janela.show(); try { janela.header.style.height = "40px"; } 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() { $i("imagemReferencia").src = ""; janela.destroy(); }; $(janela.close).click(escondeRef); if ($i("localizarxygeoProjxg")) { var temp = function() { i3GEO.coordenadas.atualizaGeo(objposicaocursor.dmsx, objposicaocursor.dmsy, "localizarxygeoProj"); }; $("#imagemReferencia").mousemove(temp); } } i3GEO.eventos.adicionaEventos("NAVEGAMAPA",["i3GEO.maparef.atualiza()"]); i3GEO.maparef.atualiza(true); $i("i3geo_winRef_h").className = "hd2"; }, /** * 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-table"; } } 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-table"; } } } 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"; } } 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() { if (typeof (console) !== 'undefined') console.info("i3GEO.maparef.atualizaBox()"); 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() { if (typeof (console) !== 'undefined') console.info("i3GEO.maparef.criaBox()"); 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); } } };